Image conversion

21 views
Skip to first unread message

Nicholas Wieland

unread,
May 21, 2008, 11:42:04 AM5/21/08
to papercli...@googlegroups.com
I can't find any example on converting images on paperclip, I would
like to upload a png and have a jpg stored ...
Somone can point me to relevant informations or example code ?

TIA,
ngw

Jonathan Yurek

unread,
May 21, 2008, 3:37:26 PM5/21/08
to papercli...@googlegroups.com
Hi, Nicholas.

You specify the format as a second argument to your styles, like so:

has_attached_file :image, :styles => { :thumb => [ "50x50", :jpg ] }

I haven't tried this, but I think it may work... if you want to
convert your original image to a new format, you could try the
following:

has_attached_file :image, :styles => { :original =>
[ "100%", :jpg ] }

... but I should reiterate I'm not sure that will work.

I hope that answers your question.

--
Jonathan Yurek
thoughtbot, inc.
jyu...@thoughtbot.com
617.482.1300 x114


Jason LaPier

unread,
May 21, 2008, 5:48:38 PM5/21/08
to papercli...@googlegroups.com
Just to verify, I'm doing this:

has_attached_file :avatar, :styles => { :original => ["64x64!", :png] }

and it does indeed work.
(The ! at the end of the size tells imagemagick that you want the
image 64x64 no matter what, even if it started out smaller than that.)

- Jason L.

--
My Rails and Linux Blog: http://offtheline.net

Reply all
Reply to author
Forward
0 new messages