IMGKit icon indicating copy to clipboard operation
IMGKit copied to clipboard

IMGKit on Heroku makes white print screen

Open misa-itk opened this issue 7 years ago • 5 comments

I am using rails api 5.2.1 and ruby 2.5.1.

My rails api application has model Location with map field which is image (carrierwave).

My goal is to make print screen of google static map and upload it to claudinary. Right not everything works fine on local. It takes print screen and upload it to claudinary storage, but when I deploy app on heroku its just make white print screen board image send it to claudinary.

My code // config/initializers/imgkit.rb

IMGKit.configure do |config|
  config.wkhtmltoimage = Rails.root.join('bin', 'wkhtmltoimage-amd64').to_s if ENV['RACK_ENV'] == 'production'
end

// models/location.rb

def take_google_map_photo
    url = GoogleMap.generate_static_map_path(self)
    file = Tempfile.new(["location-#{id}-", '.jpg'], Rails.root.join('tmp'),
                        encoding: 'ascii-8bit')
    file.write(IMGKit.new(url,
                          'no-stop-slow-scripts': true,
                          'javascript-delay': 15000,
                          'load-error-handling': 'skip', height: 670).to_jpg)
    file.flush
    self.map = file
    save!
  end

I am getting image like this

white screen image

Does somebody know how to fix this issue with HEROKU and IMGKit

misa-itk avatar Nov 16 '18 18:11 misa-itk

I'm getting this too :(

abury avatar Jan 23 '19 09:01 abury

Same problem here

Menelle avatar Feb 19 '19 01:02 Menelle

Did anyone ever find a resolution to this?

SunnyIzr avatar Nov 23 '19 00:11 SunnyIzr

I had a similar issue (working locally but not on prod/heroku).

wkhtmltoimage-binary didn't seem to like requesting urls that were https. I fetched content then passed imgkit the html and was able to render.

dunckr avatar Dec 07 '19 22:12 dunckr

wkhtmltoimage-binary didn't seem to like requesting urls that were https

Switched all image urls from https to http and it started working. 3 years later this answer helped me solve the issues with Heroku. Thank you @dunckr!

brunohq avatar Sep 05 '22 14:09 brunohq