Drarakel wrote:With very large images, "stream" is one possibility.
See also here:
http://www.imagemagick.org/Usage/files/#massive
http://www.imagemagick.org/script/stream.php
Example:
Code: Select all
stream -map rgb -storage-type char -extract 100x100+0+0 image.jpg - | convert -depth 8 -size 100x100 rgb:- output.jpg
The command gets a bit more difficult, and you also have to know the number of channels (rgb/cmyk), but this usually saves some time (especially quick with e.g. BMPs or uncompressed TIFFs) and memory.
Thank you drakael, that worked fine. The problem is that it seems that the time depends on the image size, for example:
- That with a 12000x12000 image: real 0m5.313s
That with a 30000x30000 image: 0m25.867s
that's a quite big difference, and if i want to process more larger images i think it will grow up fast.
anthony wrote:
2/ Use a JPEG specific (non-IM) program to extract just the appropriate set of 8x8 cells without decoding those cells. That image can then be read in as a smaller 'cropped' JPEG image, to then get the exact 100x100 region you want.
Hmmm I am sure that is posible, but after a quick look though jpegtran and similar files it does not appear to allow you to do this. Still I am pretty sure this is posible!
Anyone else have information?
1) A specific JPEG program like?
2) Before this i was using this code in java:
Code: Select all
public static BufferedImage readImg (String path, int startx, int starty, int w, int h){
File input = new File(path);
ImageInputStream iis = null;
try {
iis = ImageIO.createImageInputStream(input);
} catch (IOException e) {
e.printStackTrace();
}
Iterator iter = ImageIO.getImageReaders(iis);
ImageReader reader =(ImageReader)iter.next();
reader.setInput(iis,true);
ImageReadParam param = reader.getDefaultReadParam();
int imageIndex = 0;
Rectangle rect = new Rectangle(startx, starty, w, h);
param.setSourceRegion(rect);
BufferedImage bi=null;
try {
bi = reader.read(imageIndex, param);
} catch (IOException e) {
e.printStackTrace();
}
return bi;
}
and then write down the bi image with simple imageIO. That was working, in that 30000x30000 image it was extracting the data in 200ms, the problem is that going on with the image increases the time required, e.g., top left 100x100 block, 200ms, bottom right block, 40seconds.