Dear Experts,
I have some simple code that uses Magick++ to create 1/2, 1/4, 1/8,
..-size versions of a JPEG photo. This is while importing them into a
photo-browser application and because typically you'll import a large
number of photos at one time, making it fast is important (quality
needs to be good but not perfect).
Here are a couple of things that I'm already doing:
1: I use a number of threads working on different images, to exploit
multi-core processors.
2: I'm loading the original image like this, so that the initial
decompression doesn't do more work than it has to:
Image i;
i.read(Geometry(...half-size...),filename);
(It took me a long time to work out how to do this, as I was expecting
to find a constructor that would take the geometry: Image i(filename,
new_size); - could this be added?)
Here are a couple of further ideas that I've had, but have not yet
implemented; advice would be appreciated:
3: There is / was a variant of libjpeg that used MMX or SSE
instructions for improved performance. But it seems to have been
ill-maintained and for example it was removed from Debian. Is anyone
using something like this with ImageMagick?
4: I'm wondering if it's possible to make things faster by operating at
a lower level. I don't think this is possible using Magick++, but
perhaps it can be done using libjpeg; so it's a bit off-topic here, but
I'm hoping that there are some JPEG experts reading who can tell me if
it's feasible. libjpeg lets you specify scaling of 1/2, 1/4 or 1/8 to
apply during decompression. It also lets you retrieve raw data before
the actual pixel values are computed; either the raw DCT coefficients
or the data from before the colour-space conversion. So, can I
decompress with scaling, get DCT coefficients, and pass them into the
compressor? My guess is that I can't because the scaling is done after
the DCT, but I don't know that for sure. But perhaps it's possible to
take a square of 4 DCT blocks and scale them down to a single block?
Or, perhaps I should do the DCT and just bypass the colour-space
conversions. Maybe there is some other library out there that does this.
Any comments about these ideas, or other suggestions for faster
resizing to 1/2, 1/4... would be much appreciated.
Thanks, Phil.
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users