Trip
Trip

Reputation: 27114

Can you identify the current dimensions of an image with Paperclip?

I just updated the dimensions of an image thumbnail, and have been working on updating 28,000 photo objects. Unfortunately, this kind of process takes many processes over a long time to accomplish. In this process, some get rejected, and some processes get canceled.

Is there a way to identify whether an image thumbnail has the current dimensions or not?

Upvotes: 0

Views: 151

Answers (1)

apneadiving
apneadiving

Reputation: 115511

I'm unsure I understood your question but you can get the width and height of any file using Paperclip.

geo = Paperclip::Geometry.from_file(user.picture.path(:thumbnail))
geo.width
geo.height

You could get the dimensions of any style automatically:

user.picture.styles[:thumbnail].geometry # => "125x125!"

You even have some useful methods like:

geo.horizontal?
geo.vertical?

Upvotes: 3

Related Questions