Re: Loading a big image

Bob Friesenhahn <[email protected]> Fri, 24 Jul 2009 15:11:09 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
On Fri, 24 Jul 2009, jbd wrote:

> Hello,
>
> i'm wondering if there is a way to an area of a big image without loading
> everything from it ? I tried the Image::read(Geometry, filename) function but i
> think i misunderstood it since it loads a thumbnail of the original image =)

I am not totally sure what you are wanting to do.  The reason why you 
are getting a thumbnail of the original image is that your input image 
is in JPEG format and when you specify a size when the file is read, 
the JPEG library is instructed to produce a sub-resolution of the 
image which is no smaller than the size you specified.  If you planned 
to read the image and resize it based on the original image, then I am 
afraid that you will need to use the read() method without the size 
specification and then use the zoom(), scale(), sample(), minify(), or 
magnify() methods to change the image size to the desired output size 
before saving the image.

If you were planning to crop out just part of the image, then you 
still need to read the whole image and then use crop() to select the 
part you want.  This could be slow if the image is large compared to 
your computer's memory.  There is a workaround I can tell you about if 
you need to do this many times from the same image.

GraphicsMagick does not currently provide a way to extract just part 
of the image without reading the whole thing first.  I think that 
ImageMagick provides that capability , but it only works effectively 
for raw file formats (otherwise it reads the whole thing and 
automatically crops).

Bob
--
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------