# How to read image data offline without using the browser

**URL:** <https://www.ruby-forum.com/t/how-to-read-image-data-offline-without-using-the-browser/91963>\
**Category:** Rails\
**Created:** [April 13, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/how-to-read-image-data-offline-without-using-the-browser/91963 "2007-04-13T20:34:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 13, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/how-to-read-image-data-offline-without-using-the-browser/91963/1 "2007-04-13T20:34:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 14, 2007, 2:12am UTC](https://www.ruby-forum.com/t/how-to-read-image-data-offline-without-using-the-browser/91963/2 "2007-04-14T02:12:25Z")

</div>

Raj S. 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)
