# Rmagick

**URL:** <https://www.ruby-forum.com/t/rmagick/150853>\
**Category:** Rails\
**Created:** [October 14, 2008, 7:54am UTC](https://www.ruby-forum.com/t/rmagick/150853 "2008-10-14T07:54:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 7:54am UTC](https://www.ruby-forum.com/t/rmagick/150853/1 "2008-10-14T07:54:18Z")

</div>

Hi,  
I am using imagemagick and rmagick for image manipulation…

imagemagick version-6.4.4  
rmagick 2.7

I need to create a thumbnail.

```
img = Magick::Image.read(org_img_path)[0]
img.crop_resized(width,height)
img.write(new_image_path)

```

when i used this piece of code in console its cropping correctly…when  
i used inside model or lib or controller its not working.

but if i use crop\_resized! it is working but i need to maintain aspect  
ratio for that image.

If someone knows solutin for this problem kindly help me

with regards  
shiva

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 8:39am UTC](https://www.ruby-forum.com/t/rmagick/150853/2 "2008-10-14T08:39:15Z")

</div>

Shiva K. wrote:

> Hi,  
> I am using imagemagick and rmagick for image manipulation…
> 
> imagemagick version-6.4.4  
> rmagick 2.7
> 
> I need to create a thumbnail.
> 
> ```
> img = Magick::Image.read(org_img_path)[0]
> img.crop_resized(width,height)
> img.write(new_image_path)
> 
> ```
> 
> when i used this piece of code in console its cropping correctly…when  
> i used inside model or lib or controller its not working.
> 
> but if i use crop\_resized! it is working but i need to maintain aspect  
> ratio for that image.
> 
> If someone knows solutin for this problem kindly help me
> 
> with regards  
> shiva

any method ending ‘!’ will affect current object  
the remaining methods(except something like pop,shift) won’t affect  
current one  
if you want  
then use it

```
 img = Magick::Image.read(org_img_path)[0]
 img.crop_resized(width,height).write(new_image_path)

```

you can ask this doublt to your colleague like (“najnaR ro  
iallihT”.reverse)

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 9:10am UTC](https://www.ruby-forum.com/t/rmagick/150853/3 "2008-10-14T09:10:58Z")

</div>

Pokkai D. wrote:

> Shiva K. wrote:
> 
> > Hi,  
> > I am using imagemagick and rmagick for image manipulation…
> > 
> > imagemagick version-6.4.4  
> > rmagick 2.7
> > 
> > I need to create a thumbnail.
> > 
> > ```
> > img = Magick::Image.read(org_img_path)[0]
> > img.crop_resized(width,height)
> > img.write(new_image_path)
> > 
> > ```
> > 
> > when i used this piece of code in console its cropping correctly…when  
> > i used inside model or lib or controller its not working.
> > 
> > but if i use crop\_resized! it is working but i need to maintain aspect  
> > ratio for that image.
> > 
> > If someone knows solutin for this problem kindly help me
> > 
> > with regards  
> > shiva
> 
> any method ending ‘!’ will affect current object  
> the remaining methods(except something like pop,shift) won’t affect  
> current one  
> if you want  
> then use it
> 
> ```
> img = Magick::Image.read(org_img_path)[0]
> img.crop_resized(width,height).write(new_image_path)
> 
> ```
> 
> you can ask this doublt to your colleague like (“najnaR ro  
> iallihT”.reverse)

ok thanks mokkai. wht is the difference bwn wht i wrote and wht u have  
send

eg:  
img.crop\_resized(width,height)  
img.write(new\_image\_path)

and wht u have sent

img.crop\_resized(width,height).write(new\_image\_path)

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 9:29am UTC](https://www.ruby-forum.com/t/rmagick/150853/4 "2008-10-14T09:29:48Z")

</div>

Shiva K. wrote:

> > ```
> > img = Magick::Image.read(org_img_path)[0]
> > img.crop_resized(width,height).write(new_image_path)
> > 
> > ```
> > 
> > you can ask this doublt to your colleague like (“najnaR ro  
> > iallihT”.reverse)
> 
> ok thanks mokkai. wht is the difference bwn wht i wrote and wht u have  
> send
> 
> eg:  
> img.crop\_resized(width,height)  
> img.write(new\_image\_path)
> 
> and wht u have sent
> 
> img.crop\_resized(width,height).write(new\_image\_path)

it is simple  
user@ubuntu:~$ ruby -e “p ‘usarA iallihT ksA’.reverse”

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/rmagick/150853/5 "2008-10-14T13:46:56Z")

</div>

Shiva K. wrote:

> Pokkai D. wrote:
> 
> > Shiva K. wrote:  
> > eg:  
> > img.crop\_resized(width,height)  
> > img.write(new\_image\_path)
> 
> and wht u have sent
> 
> img.crop\_resized(width,height).write(new\_image\_path)

hey guys don’t get angry on me  
if u & ur tl don’t know then you can ask to others(who know).  
don’t discourge other guys who know better then you (like Ranjan and  
Thillai)  
give respect to others also, as a good developer  
i know something about that naskitasky politics in ur  
'etaroproc".reverse  
this is my small advice  
“sorry for my distrub” if “i am wrong”

by  
me(mokkai)

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 4:08pm UTC](https://www.ruby-forum.com/t/rmagick/150853/6 "2008-10-14T16:08:34Z")

</div>

Mr. Thanniarasu wht’s ur problem…

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 15, 2008, 7:21am UTC](https://www.ruby-forum.com/t/rmagick/150853/7 "2008-10-15T07:21:05Z")

</div>

Sniper A. wrote:

> ghost rider wrote:
> 
> > Mr. Thanniarasu wht’s ur problem…
> 
> who is that joker ?

no reply…

r u there ? | r u sleeping…?

---

<div class="post-metadata">

**Author:** ![shiva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85e7bf/32.png) [@shiva](https://www.ruby-forum.com/u/shiva)\
**Post date:** [October 14, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/rmagick/150853/8 "2008-10-14T16:13:13Z")

</div>

ghost rider wrote:

> Mr. Thanniarasu wht’s ur problem…

who is that joker ?
