Image manipulation/resizing server-side?


#1

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


#2

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/


#3

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)


#4

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


#5

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

Jeff


#6

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


#7

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://read.saush.com
http://jaccal.sourceforge.net


#8

Have you installed ImageMagick?


#9

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://read.saush.com
http://jaccal.sourceforge.net


#10

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


#11

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

Jeff


#12

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


#13

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

Jeff


#14

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.


#15

Try the documentation at http://manuals.rubyonrails.com/read/book/10

Joseph G. wrote:


Sau S.

http://www.saush.com
http://read.saush.com
http://jaccal.sourceforge.net