我尝试了以下代码将自定义字体添加到imglyKit SDK中,但没有添加自定义字体.我还将.ttf文件作为资源放入info.plist文件中.
let sampleImage = image.image
let configuration = Configuration() { builder in
FontImporter.init().importFonts()
builder.configurePhotoEditorViewController({ (editPhotoOption) in
editPhotoOption.allowedPhotoEditorActions = [.text]
editPhotoOption.actionButtonConfigurationClosure = {cell, _ in
cell.captionLabel.text = "Add Text"
//cell.backgroundColor = UIColor.red
}
editPhotoOption.backgroundColor = UIColor.brown
editPhotoOption.allowsPreviewImageZoom = false
})
builder.configureToolStackController({ (toolStackOption) in
toolStackOption.mainToolbarBackgroundColor = UIColor.red
toolStackOption.secondaryToolbarBackgroundColor = UIColor.brown
})
builder.configureTextFontToolController({ (textFontToolOption) in
var fontArray = [String]()
fontArray = ["AlexBrush_Regular.ttf", "Arabella.ttf"]
textFontToolOption.accessibilityElements = fontArray
textFontToolOption.actionButtonConfigurationClosure = { cell, _ in
cell.backgroundColor = UIColor.red
}
})
builder.configureTextToolController({ (textToolOption) in
textToolOption.textViewConfigurationClosure = …Run Code Online (Sandbox Code Playgroud) 我正在使用imgkit我的网页快照.我跑:
RAILS_ENV=production bundle exec rake assets:precompile 预编译我的资产.
app/assets目录的所有文件都编译为public/assets
application.css编译为application-7a23a105125768e41d9d24aee4553615.css.
我的控制器代码是:
kit = IMGKit.new(render_to_string(:partial => 'form', :height => 200, :transparent => true, :quality => 10, :layout => false,:locals => {:project => @project}))
# t = kit.to_img(:png)
kit.stylesheets << "#{Rails.root.to_s}/public/assets/application.css"
#file = kit.to_file(Rails.root + "public/pngs/" + "screenshot.png")
file = kit.to_file(Rails.root + "public/assets/" + "screenshot.png")
#send_file("#{Rails.root.to_s}/public/pngs/screenshot.png", :filename => "screenshot.png", :type => "image/png",:disposition => 'attachment',:streaming=> 'true')
Run Code Online (Sandbox Code Playgroud)
我不知道怎么解决/public/assets/application.css没找到错误...
没有这样的文件或目录 - public/assets/application.css
我正在使用https://github.com/csquared/IMGKit/issues/36获取css并在我的快照中工作
编辑
def …Run Code Online (Sandbox Code Playgroud) 我在我的一个项目中使用 IMGKIT,并且必须使用它们的 css 和 html 选项来满足要求。我注意到如果样式表设置如下:
kit = IMGKit.new(html, :quality => 50)
kit.stylesheets << '/path/to/css/file'
Run Code Online (Sandbox Code Playgroud)
并且样式表具有带有相对 url('image.png') 的背景属性,使用 kit.to_file 导出图像时不会生成图像:
(Rails.root + "public/pngs/" + "image.png")
Run Code Online (Sandbox Code Playgroud)
请求挂起,如果我们将后台 url 替换为包含协议、主机和端口的完整 url,则可以很好地导出。
我是否需要在样式表中拥有所有图像的绝对 URL?
我尝试在development.rb 文件中定义 asset_host :
config.action_controller.asset_host = Proc.new { |source|
"#{request.protocol}#{request.host_with_port}"
}
Run Code Online (Sandbox Code Playgroud)
如果我在浏览器上检查,它确实会替换 css 中的 url,但通过 IMGKIT 导出时仍然不会生成图像。
我是 Python 的新手,在学习 imgkit (PI 模块)时,我遇到了这个错误,这对于简单的代码来说是意想不到的。下面是代码
import imgkit
imgkit.from_url('https://www.google.co.in/','fs.jpg')
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
Traceback (most recent call last):
File "G:\python\lib\site-packages\imgkit-0.1.8-py3.6.egg\imgkit\config.py", line 30, in __init__
with open(self.wkhtmltoimage):
FileNotFoundError: [Errno 2] No such file or directory: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ALEXANDER\Desktop\def img.py", line 3, in <module>
imgkit.from_url('https://www.google.co.in/','fs.jpg')
File "G:\python\lib\site-packages\imgkit-0.1.8-py3.6.egg\imgkit\api.py", line 20, in from_url
rtn = IMGKit(url, 'url', options=options, toc=toc, cover=cover, config=config, cover_first=cover_first)
File "G:\python\lib\site-packages\imgkit-0.1.8-py3.6.egg\imgkit\imgkit.py", line 34, in __init__
self.config = Config() if not …Run Code Online (Sandbox Code Playgroud)