Forum: Ruby on Rails How to read image data offline without using the browser

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
934f858e451cf9b771996b2940cd696b?d=identicon&s=25 Raj Singh (dorelal)
on 2007-04-13 20:34
(Received via mailing list)
Hi,

I uploaded a lot of images and resized them using RMagick and everything
is
working fine.

Now I need to resize the existing images to some different dimenstion.
In my
existing controller all the processing starts after I have
params[:image][:data] in my controller.

My question is how do I get the image data when I am reading the file.
Does
anyone have an existing code to read an image and get something similar
to
params[:image][:data] ready for processsing. I knwo how to read an ASCII
file but don't know how to read an image file.

Thanks
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (squeegy)
on 2007-04-14 02:12
Raj Singh wrote:
> Hi,
>
> I uploaded a lot of images and resized them using RMagick and everything
> is
> working fine.
>
> Now I need to resize the existing images to some different dimenstion.
> In my
> existing controller all the processing starts after I have
> params[:image][:data] in my controller.
>
> My question is how do I get the image data when I am reading the file.
> Does
> anyone have an existing code to read an image and get something similar
> to
> params[:image][:data] ready for processsing. I knwo how to read an ASCII
> file but don't know how to read an image file.
>
> Thanks

You can get an Magick::Image object that you can manipulate with a
snippet like this:

  img = Magick::Image.read('/path/to/file.jpg').first
  img.crop_resized!(400, 300)
This topic is locked and can not be replied to.