You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bjnord edited this page Feb 10, 2012
·
9 revisions
Simple trick to get the image dimensions generated by some version:
classLogoUploader < CarrierWave::Uploader::Base# ... version:showdo# do the processing you needprocess:resize_to_limit=>[500,500]# and, here comes the trick, use some processor to access the file generatedprocess:get_version_dimensionsenddefget_version_dimensionswidth,height=`identify -format "%wx%h" #{file.path}`.split(/x/)end# ...end
If you have enabled RMagick, there's a more direct way to obtain the dimensions (without using the external "identify" program), as well as storing them in your model. As found on this page via Stack Overflow: