ImageMagick & Kindle

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
silver18
Posts: 3
Joined: 2012-10-17T12:33:44-07:00
Authentication code: 67789

ImageMagick & Kindle

Post 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!!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: ImageMagick & Kindle

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagick & Kindle

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
silver18
Posts: 3
Joined: 2012-10-17T12:33:44-07:00
Authentication code: 67789

Re: ImageMagick & Kindle

Post 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!!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagick & Kindle

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
silver18
Posts: 3
Joined: 2012-10-17T12:33:44-07:00
Authentication code: 67789

Re: ImageMagick & Kindle

Post by silver18 »

Thanks once again!!!
I wish I could learn more about IM....It seems I have lots to read! :D
Post Reply