[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby & Images

Jonathan Heinen

5/18/2006 3:52:00 PM

Hello,

i'm just starting with ruby! =) ... i would better say with ruby on rails!
Now I want to maipulate some pictures (resize for first)! I found RMagic
and MiniMagic! .. Both make use of ImageMagic! Aren't there any
standalone ruby solutions? When not! Why not? Id should be posible to
load and manipulate the files? Or are there any preformance problems
manipulating big files?

Jonathan
4 Answers

James Herdman

5/18/2006 4:13:00 PM

0

My educated guess is that Rmagick and the like are required as you need
libraries and algorithms to manipulate, handle, and understand the data
held within an image, hence the need for ImageMagick. I suppose you
could do this with pure Ruby but the performance hit would be
devastating.

James H

senthil.nayagam@gmail.com

5/18/2006 5:35:00 PM

0

why do you want to reinvent the wheel again?

in my early programming career, have attempted it, but there are far
too many formats, standards and gotchas.

i am not discouraging you,

limited set of formats for specific needs is more viable, ming(flash)
and pure php/ruby pdf implementation are sucessful examples.

if you do it yourself, you can impress your friends, colleagues and
potential employers

regards
A.Senthil Nayagam

Tim Hunter

5/18/2006 11:40:00 PM

0

Jonathan Heinen wrote:
> Hello,
>
> i'm just starting with ruby! =) ... i would better say with ruby on rails!
> Now I want to maipulate some pictures (resize for first)! I found RMagic
> and MiniMagic! .. Both make use of ImageMagic! Aren't there any
> standalone ruby solutions? When not! Why not? Id should be posible to
> load and manipulate the files? Or are there any preformance problems
> manipulating big files?
>
> Jonathan

Performance is the big issue, imo, followed by reliability and breadth
of features. As far as I know there are two big players in the open
source image processing field, ImageMagick (and its fork,
GraphicsMagick) and GD. I can't speak for GD but I understand it's a
very high-quality library.

Regarding performance, how big are the images you're wanting to resize?
Your off-the-shelf point 'n shoot digital camera will generate images
between 3 and 6 megapixels. That's a lot of pixels, and resizing (to
make thumbnails, for example) requires a lot of arithmetic per pixel to
produce a quality result. Ruby has many fine features but speed is
not its strong point.

Regarding reliability and breadth of features, I know a little bit about
ImageMagick. It's been available since 1990 (so it's about the same age
as Linux) and it currently supports over 95 image formats, including all
the biggies like JPG, GIF, PNG, TIFF, PDF, EPS, WMF, BMP, MPEG, etc. and
a lot of the not-so-biggies like the IBM PC Paintbrush file format.
There easily over 100 functions in its API. It has 4 different functions
just for resizing alone, and the main one, ResizeImage, accepts 15
different "filter" options to control how the resizing is done. (You
might choose a different filter to resize, say, a CAD drawing than the
one you'd choose when resizing a digital photograph.) All of these
functions are carefully tuned to handle very large images.

The cost of all this functionality is that ImageMagick can be a chore to
install, depending on the platform you choose. ImageMagick relies on a
dependent libraries (like libjpeg, libtiff, libpng, etc.) to do read and
write most of the file formats it supports, so you have to install the
dependent libraries before you can even start installing ImageMagick. If
your platform makes these libraries available as binary installs (via
apt-get or urpmi, for example) then the job is easier.

lloyd@binaryten.com

5/19/2006 1:11:00 PM

0

the *magic packages you mention are specifically designed to do
something and do it well - manipulate image formats. Bearing in mind
earlier comments about reinventing the wheel it makes sense to have an
external expert to come in and do a very specific job. manipulating
binary images is far quicker in rmagick due to its use of c wrapper
libraries and although it would be brilliant to be able to include this
functionality, which is certainly possible by extending ruby with its c
interface, the trade-off would be a lot more additional code in the
core ruby language for a task that doesnt get used that often, to
compare with string, text, files manipulations to mention a few