ok, im back.
has_attached_file :photo, :styles => { :original => ["100%", :jpg], }
<=== this here is incomplete and is you are only having the original
image there is no need to specify the style, and paperclip
wont convert the image to jpg, also is not good to put
convertion in the same thread as the main app.
def height()
uploaded_file = photo.queued_for_write[:original]
dimensions = Paperclip::Geometry.from_file(uploaded_file) <==== is
better to save the image in a specific size by doing
return
dimensions.height
:styles=>{:small=>"150x150>",:big=>"900x900>"}
end
def width()
uploaded_file = photo.queued_for_write[:original]
dimensions = Paperclip::Geometry.from_file(uploaded_file) <==== is
better to save the image in a specific size by doing
return
dimensions.width
:styles=>{:small=>"150x150>",:big=>"900x900>"}
end
end
them you always know the correct size, but anyway your question is wrong as
this has nothing to do with models, your height() are unnecesary as you
should just save the width and height on the save event as properties.
add width and hieght as fields of the table.
def before_save
baunds = Paperclip::geometry.from_file(uploaded_file(:original))
width = bounds.width
height = bounds.height
end
then instanciate and object and call the properties from it
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.