# RMagick at dreamhost

**URL:** <https://www.ruby-forum.com/t/rmagick-at-dreamhost/84311>\
**Category:** Rails\
**Created:** [February 3, 2007, 12:13am UTC](https://www.ruby-forum.com/t/rmagick-at-dreamhost/84311 "2007-02-03T00:13:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![costi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@costi](https://www.ruby-forum.com/u/costi)\
**Post date:** [February 3, 2007, 12:13am UTC](https://www.ruby-forum.com/t/rmagick-at-dreamhost/84311/1 "2007-02-03T00:13:09Z")

</div>

I’m getting the crazy error “undefined method `resize\_to\_fit’ for  
#Magick::Image:0x41b74904”

I have RMagick on dreamhost, but no resize\_to\_fit method? Am I missing  
something?

---

<div class="post-metadata">

**Author:** ![costi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@costi](https://www.ruby-forum.com/u/costi)\
**Post date:** [February 3, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/rmagick-at-dreamhost/84311/2 "2007-02-03T23:07:09Z")

</div>

Constantin G. wrote:

> I’m getting the crazy error “undefined method `resize\_to\_fit’ for  
> #Magick::Image:0x41b74904”
> 
> I have RMagick on dreamhost, but no resize\_to\_fit method? Am I missing  
> something?

You may be missing a sufficiently recent version of RMagick. The  
resize\_to\_fit method was added in version 1.11.0. What version of  
RMagick is installed? Try this:

ruby -r RMagick -e"puts Magick::Long\_version"

If the version is older than 1.11.0, you can add it yourself. The  
Image#resize\_to\_fit method is extremely simple to write. The code for it  
in RMagick.rb is this:

```
def resize_to_fit(cols, rows)
    change_geometry(Geometry.new(cols, rows)) do |ncols, nrows|
        resize(ncols, nrows)
    end
end
```

---

<div class="post-metadata">

**Author:** ![costi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@costi](https://www.ruby-forum.com/u/costi)\
**Post date:** [February 6, 2007, 3:23am UTC](https://www.ruby-forum.com/t/rmagick-at-dreamhost/84311/3 "2007-02-06T03:23:28Z")

</div>

Tim H. wrote:

> Constantin G. wrote:
> 
> > I’m getting the crazy error “undefined method `resize\_to\_fit’ for  
> > #Magick::Image:0x41b74904”
> > 
> > I have RMagick on dreamhost, but no resize\_to\_fit method? Am I missing  
> > something?
> 
> You may be missing a sufficiently recent version of RMagick. The  
> resize\_to\_fit method was added in version 1.11.0. What version of  
> RMagick is installed? Try this:
> 
> ruby -r RMagick -e"puts Magick::Long\_version"
> 
> If the version is older than 1.11.0, you can add it yourself. The  
> Image#resize\_to\_fit method is extremely simple to write. The code for it  
> in RMagick.rb is this:
> 
> ```
> def resize_to_fit(cols, rows)
> change_geometry(Geometry.new(cols, rows)) do |ncols, nrows|
> resize(ncols, nrows)
> end
> end
> 
> ```

Indeed on my host ([clamato.dreamhost.com](http://clamato.dreamhost.com)) I have Rmagick 1.6.0, a 2004  
build.  
This is RMagick 1.6.0 ($Date: 2004/08/18 23:22:36 $) Copyright (C) 2004  
by Timothy P. Hunter

This is my first public rails website and I’m still learning. Your  
solution was perfect. I just added this on top of my model.rb. It needed  
a small modification, so I’m posting this here, maybe to help another  
newbie.

# quick hack for dreamhost for an old version of RMagick

class Magick::Image  
def resize\_to\_fit!(cols, rows)  
change\_geometry(Magick::Geometry.new(cols, rows)) do |ncols, nrows|  
resize!(ncols, nrows)  
end  
end

def resize\_to\_fit(cols, rows)  
change\_geometry(Magick::Geometry.new(cols, rows)) do |ncols, nrows|  
resize(ncols, nrows)  
end  
end  
end
