gkaykck
gkaykck

Reputation: 261

RMagick - S3 - Heroku, problems with RMagick file open

I am trying to upload a file from browser, then make one thumbnail from it, then upload both to s3.

 File.open(params[:file][:tempfile]) do |p|
      AWS::S3::Base.establish_connection!(
          :access_key_id     => settings.s3_key,
          :secret_access_key => settings.s3_secret)
      AWS::S3::S3Object.store(pic_name,p,settings.bucket,:access => :public_read)

      thumb = Magick::Image.read(p)
      thumb.crop_resized!(75, 75, Magick::NorthGravity)

      AWS::S3::Base.establish_connection!(
          :access_key_id     => settings.s3_key,
          :secret_access_key => settings.s3_secret)
      AWS::S3::S3Object.store(pic_name + "s",thumb,settings.bucket,:access => :public_read)

I have tried most of the possible code combinations to make it work, but it gives me a segmentation error

c:0060 p:---- s:0261 b:0261 l:000260 d:000260 CFUNC  :read
c:0059 p:0117 s:0257 b:0257 l:002638 d:000256 BLOCK  /Users/gkay/Documents/yirmiyedi/web/banne/app/controllers/firsat.rb:33
c:0058 p:---- s:0253 b:0253 l:000252 d:000252 FINISH
c:0057 p:---- s:0251 b:0251 l:000250 d:000250 CFUNC  :open
c:0056 p:0190 s:0247 b:0247 l:002638 d:000246 LAMBDA /Users/gkay/Documents/yirmiyedi/web/banne/app/controllers/firsat.rb:27

So it starts when RMagic tries to open the file. I have tried many stuff like

thumb = Magick::Image.read(p).first or [0] etc but none of them worked.

Any ideas? params[:file] is the post param which keeps the file

Upvotes: 0

Views: 909

Answers (4)

umezo
umezo

Reputation: 1579

For any newer visitors, ImageMagick currently works on Heroku without RMagick, so no need to include it in your gemfile.

However, if you're using Paperclip, you'll need to specify gem 'cocaine', '0.3.2', as noted in this post, as some other versions do not work.

Upvotes: 0

gkaykck
gkaykck

Reputation: 261

The problem solved when i uninstalled the imagemagick, uninstalled rmagick gem, installed imagemagick without openmp, then installed rmagick gem again.

Upvotes: 0

Bozhidar Batsov
Bozhidar Batsov

Reputation: 56605

I'd suggest using Mini Magick instead - it uses a lot less memory and it's much less buggy. We've had a lot of problems with RMagick, but none with mini magick. And switching from one to the other is very easy.

Upvotes: 1

DAddYE
DAddYE

Reputation: 1729

Try adding

GC.start

At top of your code

Upvotes: 0

Related Questions