# Image manipulation/resizing server-side?

**URL:** <https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010>\
**Category:** Rails\
**Created:** [March 27, 2006, 9:32am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010 "2006-03-27T09:32:33Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 27, 2006, 9:32am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/1 "2006-03-27T09:32:33Z")

</div>

I’d like to implement a system in a Rails app where I allow the user to  
upload an image file, and then the app takes that image and manipulates  
it, saving a thumbnail, small, and original size version of the file to  
the server.

How would I go about doing that?

Thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 27, 2006, 9:38am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/2 "2006-03-27T09:38:36Z")

</div>

Jeff C.man wrote:

> I’d like to implement a system in a Rails app where I allow the user to  
> upload an image file, and then the app takes that image and manipulates  
> it, saving a thumbnail, small, and original size version of the file to  
> the server.
> 
> How would I go about doing that?

ruby bindings to libimagemagick, [http://rmagick.rubyforge.org/](http://rmagick.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 27, 2006, 10:49am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/3 "2006-03-27T10:49:53Z")

</div>

You should have a look to mini\_magick which is less resource demanding  
than RMagick.

Then it’s just a simple as :

thumbnail = MiniMagick::Image.from\_file(src\_filename)  
thumbnail.resize “500x400”  
thumbnail.write(dst\_filename)

You need to have imagemagick installed (native application)

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 28, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/4 "2006-03-28T17:05:24Z")

</div>

I’m having trouble using gem to install either RubyMagick or  
Mini-Magick.

This is what happens when I try to install RMagick on my Windows XP  
computer:

C:\rails\>gem install rmagick --include-dependencies  
Attempting local installation of ‘rmagick’  
Building native extensions. This could take a while…  
configure:1: Can’t exec \bin\sh (fatal)  
ERROR: Error installing gem rmagick[.gem]: ERROR: Failed t  
tension.  
Gem files will remain installed in c:/ruby/lib/ruby/gems/1.  
for inspection.  
ruby configure install rmagick --include-dependencies\n

What am I doing wrong?

Thanks,

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 28, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/5 "2006-03-28T17:05:51Z")

</div>

That full error message should be “Failed to build native extension”.

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 27, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/6 "2006-03-27T18:00:35Z")

</div>

Christophe G. wrote:

> You should have a look to mini\_magick which is less resource demanding  
> than RMagick.
> 
> Then it’s just a simple as :
> 
> thumbnail = MiniMagick::Image.from\_file(src\_filename)  
> thumbnail.resize “500x400”  
> thumbnail.write(dst\_filename)
> 
> You need to have imagemagick installed (native application)

Nice! Thanks for the info.

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 28, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/7 "2006-03-28T17:44:21Z")

</div>

You need to install the gem locally. Download it first from the site and  
do a local installation of the gem.

Jeff C.man wrote:

> ERROR: Error installing gem rmagick[.gem]: ERROR: Failed t

–  
Sau S.

[http://www.saush.com](http://www.saush.com)  
[http://read.saush.com](http://read.saush.com)  
[http://jaccal.sourceforge.net](http://jaccal.sourceforge.net)

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 28, 2006, 8:57pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/8 "2006-03-28T20:57:58Z")

</div>

Have you installed ImageMagick?

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 28, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/9 "2006-03-28T19:27:33Z")

</div>

I’m afraid I get the same message when I try to install it locally:

C:\rails\>gem install -l rmagick-1.10.1  
Attempting local installation of ‘rmagick-1.10.1’  
Building native extensions. This could take a while…  
configure:1: Can’t exec \bin\sh (fatal)  
ERROR: Error installing gem rmagick-1.10.1[.gem]: ERROR: Failed to  
build gem na  
tive extension.  
Gem files will remain installed in  
c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.1  
for inspection.  
ruby configure install -l rmagick-1.10.1\n

Results logged to  
c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.1/gem\_make.out

Again I’m sure there must be something very obvious I’m missing, but I’m  
not sure what it could be…

Jeff

Chang Sau S. wrote:

> You need to install the gem locally. Download it first from the site and  
> do a local installation of the gem.
> 
> Jeff C.man wrote:
> 
> > ERROR: Error installing gem rmagick[.gem]: ERROR: Failed t
> 
> –  
> Sau S.
> 
> [http://www.saush.com](http://www.saush.com)  
> [http://read.saush.com](http://read.saush.com)  
> [http://jaccal.sourceforge.net](http://jaccal.sourceforge.net)

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 6:32am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/10 "2006-03-29T06:32:36Z")

</div>

This is just another note to see if anyone has any idea why the RMagick  
gem won’t install, either locally or remotely. Anyone?

Jeff C.man wrote:

> I’m afraid I get the same message when I try to install it locally:
> 
> C:\rails\>gem install -l rmagick-1.10.1  
> Attempting local installation of ‘rmagick-1.10.1’  
> Building native extensions. This could take a while…  
> configure:1: Can’t exec \bin\sh (fatal)  
> ERROR: Error installing gem rmagick-1.10.1[.gem]: ERROR: Failed to  
> build gem na  
> tive extension.  
> Gem files will remain installed in  
> c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.1  
> for inspection.  
> ruby configure install -l rmagick-1.10.1\n
> 
> Results logged to  
> c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.1/gem\_make.out

Thanks,

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 28, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/11 "2006-03-28T21:07:04Z")

</div>

Carl-Johan K. wrote:

> Have you installed ImageMagick?

I have installed the ImageMagick DLL installer for Windows found here:  
[http://www.imagemagick.org/download/binaries/ImageMagick-6.2.6-6-Q16-windows-dll.exe](http://www.imagemagick.org/download/binaries/ImageMagick-6.2.6-6-Q16-windows-dll.exe)

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 6:48am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/12 "2006-03-29T06:48:10Z")

</div>

Jeff C.man wrote:

> > ERROR: Error installing gem rmagick-1.10.1[.gem]: ERROR: Failed to  
> > build gem na  
> > tive extension.  
> > Gem files will remain installed in  
> > c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.1  
> > for inspection.  
> > ruby configure install -l rmagick-1.10.1\n
> > 
> > Results logged to  
> > c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.1/gem\_make.out

You are trying to execute a shell script in a DOS shell.

\bin\sh is the path to a Unix command interpreter, and you more than  
likely don’t have it and if you do, it is not in \bin or c:\bin

Drilling down, the program that is trying to execute itself with sh is  
the program configure, which is a gnu utility to configure a program to  
be built in a particular environment.

Long story short, you are either trying to the wrong package (you  
downloaded the Unix or maybe Cygwin version of rmagick), or you need to  
be building rmagick in Cygwin.

I don’t have any first hand knowledge of using gem in Windows, but that  
should point you in the right general direction.

–

Ray

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 7:10am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/13 "2006-03-29T07:10:46Z")

</div>

Thanks, Ray, you were exactly right. I did a bit more digging and found  
the appropriate Win32 installers and instructions. 🙂

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 7:03am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/14 "2006-03-29T07:03:31Z")

</div>

Hello,  
I was wondering if anyone could point me to a plugin or framework on how  
to  
expose SOAP services via rails controllers. I am particularly  
interested in  
being able to post a SOAP document as an attachment and handle it in the  
controller. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 8:17am UTC](https://www.ruby-forum.com/t/image-manipulation-resizing-server-side/56010/15 "2006-03-29T08:17:15Z")

</div>

Try the documentation at [Peak Obsession](http://manuals.rubyonrails.com/read/book/10)

Joseph G. wrote:

> 

–  
Sau S.

[http://www.saush.com](http://www.saush.com)  
[http://read.saush.com](http://read.saush.com)  
[http://jaccal.sourceforge.net](http://jaccal.sourceforge.net)
