Split huge image file without reading entire file

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
danc81
Posts: 7
Joined: 2012-01-23T12:18:56-07:00
Authentication code: 8675308

Split huge image file without reading entire file

Post by danc81 »

I have a file which is around 100000 x 100000 pixels, I would like to crop into smaller images which I'm doing with:

convert input.jpg -crop 100x100 +repage output_%d.jpg

This is working but it takes a very long time and a huge amount of memory to open the file. Is there a way to do this without opening the entire file first?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Split huge image file without reading entire file

Post by fmw42 »

I am not an expert on large image processing. All I can do is refer you to http://www.imagemagick.org/Usage/files/#massive
danc81
Posts: 7
Joined: 2012-01-23T12:18:56-07:00
Authentication code: 8675308

Re: Split huge image file without reading entire file

Post by danc81 »

Thanks, I've been reading through that and adjusting memory limits etc but it still takes a very long time (10 mins+) to open the file whereas something like GIMP can open it and start processing in < 10 secs. Not sure if this is expected or if I'm doing something wrong.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Split huge image file without reading entire file

Post by anthony »

Gimp uses a caching method that allow part of an image to be in memory.

IM "stream" command can read an image one row at a time and process the image, but is really limited to 'cropping' one section only.

PBMplus should be able to do stream processing, but little in the way of non-source documentation exists for this aspect, and only works with its own internal image file formats.

Ideally we want a 'stream' image processor that can not only split up an image into tiles, but also re-join tiles back into a large image.

The latter aspect seems to be less thought about, but just as nessary!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply