the rmagick manual is quite vague. can you help me by changing a pictures filetype and size?
Posted
by Joern Akkermann
on Stack Overflow
See other posts from Stack Overflow
or by Joern Akkermann
Published on 2010-03-08T17:49:51Z
Indexed on
2010/03/08
17:51 UTC
Read the original article
Hit count: 373
ruby-on-rails
|rmagick
Hi,
it's about RMagick with Ruby On Rails.
I do the following:
image = params[:image]
# params[:image] is the image from the file-form.
name = image.original_filename.scan(/[^\/\\]+/).last
name = dir + t.day.to_s + t.month.to_s + t.year.to_s + t.hour.to_s + t.min.to_s + t.sec.to_s + name
f = File.new(name, "wb")
f.write image
f.close
image = Magick::Image.read(name)
image = image.resize_to_fit(200, 250)
f = File.new(name, "wb")
f.write image.to_blob
f.close
Do I really need to first save and then change it? And how about changing not only the size, changing also the Filetype? I want a JPG with 60% quality.
Please help me.
Yours, Joern.
© Stack Overflow or respective owner