Page 1 of 1

ImageMagick & Kindle

Posted: 2012-10-17T12:42:04-07:00
by silver18
Good evening!
I'm new here so, first of all, thanks for ImageMagick!!

I'm using it in my Kindle Touch (Version: ImageMagick 6.6.9-5 2012-07-17 Q16 http://www.imagemagick.org) to resize some images.
It works really fine but I encountered a problem with big images (~9Mb).
I use this command:

Code: Select all

convert input.jpg -thumbnail 260 -quality 30 output.jpg
and it gives me this image:
Image

I know it's something related with the filesize and the low memory on the Kindle.
This is the output of -list resource

Code: Select all

File         Area       Memory          Map         Disk    Thread         Time
-------------------------------------------------------------------------------
 768      65.45MB     249.7MiB     499.4MiB    unlimited         1    unlimited
But I can't get it to work even by setting -limit.
Any clue?
Thanks to all!!

Re: ImageMagick & Kindle

Posted: 2012-10-17T18:28:58-07:00
by glennrp
It might help to give the JPEG decoder a hint with "-define jpeg:size=256", i.e.,

Code: Select all

convert -define jpeg:size=256 input.jpg -thumbnail 260 -quality 30 output.jpg

Re: ImageMagick & Kindle

Posted: 2012-10-17T21:30:24-07:00
by anthony
A better hint would be 512.

The decode will read in and 'sample' the jpeg image between the power of 2 value given and the next power of two upward. In this case the image will be between 512 and 1024. the thumbnail/resize will take it from there.

if you used 256, you may get a sampled image that was 256 pixels wide and then need to be enlarged to 260.
Samplied images are very aliased images (equivalent to a 'point' filter). It is best to sample at 2 to 4 times larger than the final size.
The -thumbnail operator actually does that for speed as well, but it is better for the jpeg codec to do it.

See image thunbnails, General
http://www.imagemagick.org/Usage/thumbnails/

and Sample Operator
http://www.imagemagick.org/Usage/resize/#sample

Re: ImageMagick & Kindle

Posted: 2012-10-18T02:39:14-07:00
by silver18
Thanks a lot!!
That really worked fine!

Just two more questions...

if I use -thumbnail 260 I should use -define jpeg:size=512...But what if I use -thumbnail 194? Should I use 256 or 512 again?

Is there any way of speed it up? As I use this command in a while loop, it converts lots of images and this results in quite a huge amount of time!

Thanks again!!

Re: ImageMagick & Kindle

Posted: 2012-10-18T17:13:02-07:00
by anthony
silver18 wrote:if I use -thumbnail 260 I should use -define jpeg:size=512...But what if I use -thumbnail 194? Should I use 256 or 512 again?
That depends on quality you want. Remember jpeg size just junks (samples) most of the pixels, but does so without needing to allocate memory for the image. -thumbnail or -resize merges (filters, or weighted averages) pixels together to produce a better quality resize. A larger image given to resize will be slower, but of higher quality.

There are other resize techniques that produce even higher quality but at a speed cost, these require a lot of study to understand and apply, but a summary is given by Nicholas Robidoux in IM Examples, Resampling Filters
http://www.imagemagick.org/Usage/filters/

Code: Select all

Is there any way of speed it up? As I use this command in a while loop, it converts lots of images and this results in quite a huge amount of time!
Note really. Again it depends on the quality. A lot of the time will be either simple disk I/O or Jpeg decoding, and again re-encoding to write to the disk. If you are generating montages of the smaller images so time savings can be generated by avoiding writing to disk using, all in one commands, or pipelines of raw MIFF data.

See also IM Examples, API's, Making IM Faster (in general)
http://www.imagemagick.org/Usage/api/#speed

Re: ImageMagick & Kindle

Posted: 2012-10-19T06:15:04-07:00
by silver18
Thanks once again!!!
I wish I could learn more about IM....It seems I have lots to read! :D