You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use imgkit in a rails controller with send_data and imgkit.to_png
This results in an image sent that is 1 byte too short and a broken image.
However, if I save the data to a file with imgkit.to_file, and then tell rails to send that with send_file it works.
I'm on Windows 10 x64, ruby 2.0, rails 4.2.0, imgkit 1.6.1, wkhtmltoimage 0.12.2.4
I can't figure out what is wrong, but my hunch is that this is an encoding issue. The strings(blobs) show up as ASCII-8BIT
kit = IMGKit.new(html)
image_data = kit.to_png
file = kit.to_file('myfile.png')
send_file('myfile.png', :type => "image/png", :disposition => 'inline') # THIS WORKS
send_data image_data, type: 'image/png', :disposition => 'inline' #THIS DOES NOT
The text was updated successfully, but these errors were encountered:
More info. I tried re-reading the file that was created with .to_file with IO.binread('myfile.png') into a string variable and then and using that string as a param with send_data and that works.
It looks like the inter-process pipe between imgkit and the wkhtmltoimage executable is where the problem arises.
I'm trying to use imgkit in a rails controller with send_data and imgkit.to_png
This results in an image sent that is 1 byte too short and a broken image.
However, if I save the data to a file with imgkit.to_file, and then tell rails to send that with send_file it works.
I'm on Windows 10 x64, ruby 2.0, rails 4.2.0, imgkit 1.6.1, wkhtmltoimage 0.12.2.4
I can't figure out what is wrong, but my hunch is that this is an encoding issue. The strings(blobs) show up as ASCII-8BIT
The text was updated successfully, but these errors were encountered: