# Attachement\_fu : resize\_to's not working

**URL:** <https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338>\
**Category:** Rails\
**Created:** [August 31, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338 "2008-08-31T16:06:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbnnt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@bbnnt](https://www.ruby-forum.com/u/bbnnt)\
**Post date:** [August 31, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338/1 "2008-08-31T16:06:40Z")

</div>

with the following asset.rb model :

has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:processor =\> ‘Rmagick’,  
:path\_prefix =\> ‘/public/assets/’,  
:size =\> 0.kilobytes…100000.kilobytes,  
:max\_size =\> 10.megabytes,  
:resize\_to =\> ‘580x400\>’,  
:thumbnails =\> { :panorama\_cropped =\>  
‘580x400!’, :panorama =\> ‘580x400\>’, :medium =\> ‘250x150\>’,  
:medium\_cropped =\> ‘250x150!’, :thumb =\> ‘75x60!’ }

and rmagick’s attachment\_fu processor hacked like this :

def resize\_image(img, size)  
size = size.first if size.is\_a?(Array) && size.length == 1 &&  
!size.first.is\_a?(Fixnum)  
if size.is\_a?(Fixnum) || (size.is\_a?(Array) &&  
size.first.is\_a?(Fixnum))  
size = [size, size] if size.is\_a?(Fixnum)  
img.crop\_resized!(\*size)  
else  
img.change\_geometry(size.to\_s) { |cols, rows, image|  
image.crop\_resized!(cols, rows) }  
end  
self.temp\_path = write\_to\_temp\_file(img.to\_blob)  
end

i get everything working as expected on my local machine, that is to  
say, even if a have a 300x200 image, i get a 580x400 panorama\_cropped  
image as set up in the model.

putting it the server, if the image fits in a 580x400 sizes, nothin is  
done for this panorama\_cropped setup, and i just get the original format  
for this, as from the above would be 300x200.

i might have to do with the way the environnement has been set, but I  
just can’t figure out exactly from here it could come.

thanks a lot for any help about it.

---

<div class="post-metadata">

**Author:** ![bbnnt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@bbnnt](https://www.ruby-forum.com/u/bbnnt)\
**Post date:** [August 31, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338/2 "2008-08-31T17:06:47Z")

</div>

I ran into a similar problem with imagescience - it doesn’t seem to obey  
the “!” convention in rmagick geometry strings. However, if you just  
pass an array as the dimensions, it has the same effect:

:thumb =\> [580, 400]

Are you sure your server is using rmagick? If you didn’t set it up  
yourself, someone may be chosen to use imagescience instead.

---

<div class="post-metadata">

**Author:** ![bbnnt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@bbnnt](https://www.ruby-forum.com/u/bbnnt)\
**Post date:** [September 1, 2008, 8:59am UTC](https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338/3 "2008-09-01T08:59:26Z")

</div>

Bryan M. wrote:

> I ran into a similar problem with imagescience - it doesn’t seem to obey  
> the “!” convention in rmagick geometry strings. However, if you just  
> pass an array as the dimensions, it has the same effect:
> 
> :thumb =\> [580, 400]
> 
> Are you sure your server is using rmagick? If you didn’t set it up  
> yourself, someone may be chosen to use imagescience instead.

The cropping’s fineâ€¦ wich reading your answer is not that obvious the  
way it has been set up.

what i don’t get is how to have my 300x200 scaling proportionnaly to a  
580xsomething px area;  
i’m looking for having the same height for every images for every  
thumbnails’ sizes specified, 400 for panorama, 150 for medium, etcâ€¦

for the moment, if the image is under for example the 580x400  
dimensions, it is not processed at all and my @img.public\_filename() and  
@img.public\_filename(:panorama) are both the same.

---

<div class="post-metadata">

**Author:** ![bbnnt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@bbnnt](https://www.ruby-forum.com/u/bbnnt)\
**Post date:** [September 1, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338/4 "2008-09-01T18:18:27Z")

</div>

If I’m not stepping on your thread, this is a similar question I  
posted two days ago without response:

I am running Rmagick and Imagemagick just fine on my Windows XP  
machine ( thanks Rick ) and all is well in the world.  
I’ve moved the identical source deck to another machine that appears  
to have an identical work environment ( pathing to imagemagic ) and  
the application saves photos just fine, but it doesn’t do the  
THUMBNAIL thing? The photo is left in its respective subdirectory of /  
images with the correct name ( photo\_thumb.jpg ) but it has exactly  
the same weight (size) as when it was processed by Rmagick/  
Imagemagick.

Could someone venture a guess as to where I might look to explore this  
mystery?

Thank you,  
Kathleen

On Sep 1, 12:59 am, Benjamin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bbnnt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@bbnnt](https://www.ruby-forum.com/u/bbnnt)\
**Post date:** [September 1, 2008, 6:22pm UTC](https://www.ruby-forum.com/t/attachement-fu-resize-tos-not-working/147338/5 "2008-09-01T18:22:26Z")

</div>

I have the same thing on another machine too (fedora), but with this I  
assume the imagemagick install (wich seemed to work) is just wrong. I  
just gave up and wil try to reinstall it.

For the moment i’m looking for having a :resize\_to working, wich is  
broke for some reasons.

removed\_email\_address@domain.invalid wrote:

> If I’m not stepping on your thread, this is a similar question I  
> posted two days ago without response:
> 
> I am running Rmagick and Imagemagick just fine on my Windows XP  
> machine ( thanks Rick ) and all is well in the world.  
> I’ve moved the identical source deck to another machine that appears  
> to have an identical work environment ( pathing to imagemagic ) and  
> the application saves photos just fine, but it doesn’t do the  
> THUMBNAIL thing? The photo is left in its respective subdirectory of /  
> images with the correct name ( photo\_thumb.jpg ) but it has exactly  
> the same weight (size) as when it was processed by Rmagick/  
> Imagemagick.
> 
> Could someone venture a guess as to where I might look to explore this  
> mystery?
> 
> Thank you,  
> Kathleen
> 
> On Sep 1, 12:59ï¿½am, Benjamin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
