Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMGKit on Heroku makes white print screen #115

Open
misa-itk opened this issue Nov 16, 2018 · 5 comments
Open

IMGKit on Heroku makes white print screen #115

misa-itk opened this issue Nov 16, 2018 · 5 comments

Comments

@misa-itk
Copy link

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

@abury
Copy link

abury commented Jan 23, 2019

I'm getting this too :(

@Menelle
Copy link

Menelle commented Feb 19, 2019

Same problem here

@SunnyIzr
Copy link

Did anyone ever find a resolution to this?

@dunckr
Copy link

dunckr commented Dec 7, 2019

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.

@brunohq
Copy link

brunohq commented Sep 5, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants