Too slow cropping large jpg file

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
splee
Posts: 15
Joined: 2011-07-08T22:21:01-07:00
Authentication code: 8675308

Too slow cropping large jpg file

Post by splee »

I am using ImageMagick-6.7.0-Q16 and I have a Test1.jpg file which is 28800x22400pixels (800dpi, grayscale), file size 63MB.

I did a command line "convert Test1.jpg -crop 1000x1000+0+0 Test1_cropped.jpg" and it took me a long time.

My computer is Pentium Core 2 2.66GHz and has 3GB RAM, running Windows XP (x86).

Can anyone help?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Too slow cropping large jpg file

Post by fmw42 »

use -define to set the size to read from the input for jpg only.

see http://www.imagemagick.org/Usage/formats/#jpg_read
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Too slow cropping large jpg file

Post by anthony »

The jpeg_read option is for resizing, not cropping.


The problem is that IM "convert" will read the whole image into memory first (uncompressed), and as such if there is not enough space for both it and the cropped version, it will start using disk caching which takes a lot of time.

The IM "stream" command however could be used to crop the JPEG image, and pipe that into convert so that it has a more minimal image foot print.

Really Massive Image Handling
http://www.imagemagick.org/Usage/files/#massive
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
splee
Posts: 15
Joined: 2011-07-08T22:21:01-07:00
Authentication code: 8675308

Re: Too slow cropping large jpg file

Post by splee »

This seems to solve the problem:
Open Regedit and Find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\

Disable Paging Executive:
XP pages data from RAM memory to the hard drive. We can stop this happening and keep more data in RAM, resulting in better performance. Users with a large amount of RAM (256MB+) should use this setting. The setting we change to disable the 'Paging Executive', is DisablePagingExecutive. Changing the value of this key from 0 to 1 will de-activate memory paging.
splee wrote:I am using ImageMagick-6.7.0-Q16 and I have a Test1.jpg file which is 28800x22400pixels (800dpi, grayscale), file size 63MB.

I did a command line "convert Test1.jpg -crop 1000x1000+0+0 Test1_cropped.jpg" and it took me a long time.

My computer is Pentium Core 2 2.66GHz and has 3GB RAM, running Windows XP (x86).

Can anyone help?
Post Reply