0

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?

apneadiving
  • 114,565
  • 26
  • 219
  • 213
Trip
  • 26,756
  • 46
  • 158
  • 277

1 Answers1

3

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?
apneadiving
  • 114,565
  • 26
  • 219
  • 213
  • Hmm.. I tried the first example and I got a `Paperclip::NotIdentifiedByImageMagickError: photos/16526/tiny_thumb/building.jpg is not recognized by the 'identify' command.` And then second example for geometry would return what my model settings are set to. But that woudn't tell me if they were refreshed yet. So even if they are still the old dimensions, it'll show the new dimensions for geometry. – Trip Jul 25 '11 at 02:25
  • Ah! Got it! You're right. Except I didn't use `path` I used `url` Bling! Thganks so much! – Trip Jul 25 '11 at 02:29