views:

41

answers:

1

I would like to read the geometry of a photo off of my S3 container.

When it's on my local, this works :

def photo_geometry(style = :original)
  @geometry ||= {}
  @geometry[style] ||= Paperclip::Geometry.from_file photo.path(style)
end

But it doesn't seem to work when I switch my model over to S3.. Any recommendations?

The bigger story, is I'm trying to write some code that will allow me to retrieve photos from S3, allow users to crop them, and then reupload them back to S3 still assigned by paperclip.

EDIT:

This is the error that is returned :

Paperclip::NotIdentifiedByImageMagickError: photos/199/orig/greatReads.png is not recognized by the 'identify' command.
from /Users/daniellevine/Sites/hq_channel/vendor/gems/thoughtbot-paperclip-2.3.1/lib/paperclip/geometry.rb:24:in `from_file'
from /Users/daniellevine/Sites/hq_channel/app/models/photo.rb:68:in `photo_geometry'
from (irb):1
+1  A: 

If you're using S3 as a storage mechanism, you can't use the geometry method above (it assumes a local file). Paperclip can convert from S3 file to local TempFile with the Paperclip::Geometry.from_file:

Here is my updated code:

def photo_geometry(style = :original)
  @geometry ||= {}
  @geometry[style] ||= Paperclip::Geometry.from_file(photo.to_file(style)) # TODO: does not work with s3
end
Trip