Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libjpeg with image_optim gem on Heroku Cedar Stack (Ruby buildpack)

I'm trying to get the image_optim gem to work with a Rails 4 app on Heroku's Cedar stack to optimize png/gif/jpeg images.

I threw the required binaries (advpng, gifsicle, jpegoptim, jpegtran, optipng, pngcrush, pngout) into /bin and set ENV['PATH'] = "#{Rails.root}/bin:#{ENV['PATH']}" in an initializer. This works for gifs and pngs, but I'm running into problems with jpegs.

In the rails console I get:

irb(main):001:0> `jpegoptim`

jpegoptim: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory

How should I go about installing libjpeg on Heroku?

like image 483
sausman Avatar asked Jun 15 '26 00:06

sausman


1 Answers

The correct way to deploy binaries to Heroku is to use buildpacks: https://devcenter.heroku.com/articles/buildpacks

Use this one if you want to package up multiple binaries: https://github.com/ddollar/heroku-buildpack-multi

There are a number of buildpacks already created for various binaries, but none for the ones you have listed.

like image 99
ckarbass Avatar answered Jun 17 '26 19:06

ckarbass