Slice One BIG photo into many small photos at once?

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
arma
Posts: 5
Joined: Thu Apr 26, 2018 5:55 am

Slice One BIG photo into many small photos at once?

Post by arma » Sat May 05, 2018 11:28 am

Hello,

Is this possible to slice many small photos at once? Multi crop?
I have very big size photo, and i need to slice into many photo... If i do repeat -crop x1 y1 x2 y2... it takes long time. Because of photo size. I wonder if multiple crop possible at once?

Thank you.

My Photos size = 94489 x 23622
My Example:
nconvert -crop 0 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 3000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 6000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 9000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 12000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 15000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 18000 0 3000 23622 -o outfile.tif inputfile.tif
.
.
.

Total steps are around 31-32... Each Command takes long time because my photo resulation is too high... 94489 x 23622...
Is there any way to slice once photo into many sliced photos at once?

cday
XnThusiast
Posts: 1768
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Slice One BIG photo into many small photos at once?

Post by cday » Sat May 05, 2018 11:50 am

arma wrote:
Sat May 05, 2018 11:28 am
Is this possible to slice many small photos at once? Multi crop?
I have very big size photo, and i need to slice into many photo... If i do repeat -crop x1 y1 x2 y2... it takes long time. Because of photo size. I wonder if multiple crop possible at once?

Thank you.

My Photos size = 94489 x 23622
My Example:
nconvert -crop 0 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 3000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 6000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 9000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 12000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 15000 0 3000 23622 -o outfile.tif inputfile.tif
nconvert -crop 18000 0 3000 23622 -o outfile.tif inputfile.tif
.
.

Total steps are around 31-32... Each Command takes long time because my photo resulation is too high... 94489 x 23622...
Is there any way to slice once photo into many sliced photos at once?
If you are not already doing so, you could run the above code as a single batch file script .bat ...

If you mean to execute your code faster, then basically only to use more processing power...

However, as the source file has very large pixel dimensions, it *might* be possible to obtain the overall result faster by first slicing the source image into smaller pieces (quarters, for example) and then slicing those into the required final sizes, even if more operations in total are required??

arma
Posts: 5
Joined: Thu Apr 26, 2018 5:55 am

Re: Slice One BIG photo into many small photos at once?

Post by arma » Sat May 05, 2018 4:24 pm

Thank you for your answer.
I know some tricks to run this faster. But i was looking for another syntax to slide into many at once if possible.
I can do in my C code. Much more faster. Because i load to photo memory at once and produce into sliced photos at once...
I was looking the same in XnView batch if possible?

cday
XnThusiast
Posts: 1768
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Slice One BIG photo into many small photos at once?

Post by cday » Sat May 05, 2018 4:43 pm

arma wrote:
Sat May 05, 2018 4:24 pm
I know some tricks to run this faster. But i was looking for another syntax to slide into many at once if possible.
I can do in my C code. Much more faster. Because i load to photo memory at once and produce into sliced photos at once...
I was looking the same in XnView batch if possible?
NConvert can only produce one output file each time it is run...

So the only way I can see to speed up processing would be as I suggested above, which I suspect could be reasonably effective if reading the input file uses most of the processing time. Whether splitting into 1/4's or 1/8's would be optimal I don't know.

It should be easy to do some tests if you wish, as the code for processing each 1/4 or 1/8 slice would be the same for every slice made, reducing the amount of calculation or programming required.

But if you have a better way using C code, is there anything to gain by using NConvert?

arma
Posts: 5
Joined: Thu Apr 26, 2018 5:55 am

Re: Slice One BIG photo into many small photos at once?

Post by arma » Sat May 05, 2018 5:27 pm

My C code run much faster ofcourse, but i would prefer to use XnView because of compatibility of many picture format etc.
But speed is so slow :( because of this situation :(

cday
XnThusiast
Posts: 1768
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Slice One BIG photo into many small photos at once?

Post by cday » Sat May 05, 2018 6:35 pm

arma wrote:
Sat May 05, 2018 5:27 pm
My C code run much faster of course, but i would prefer to use XnView because of compatibility of many picture format etc.
But speed is so slow :( because of this situation :(
You're using the 64-bit version?

If you have no alternative for certain file formats, you could at any rate test my suggestion in different forms: you could fairly quickly test for 1/4 slices, for example, by checking if running the code required to convert the input file into one 1/4 slice, and then into the required eight output files, takes usefully less than 25% of the time required with your existing code. And if that works, possibly test with 1/8 slices.

arma
Posts: 5
Joined: Thu Apr 26, 2018 5:55 am

Re: Slice One BIG photo into many small photos at once?

Post by arma » Sat May 05, 2018 9:58 pm

i slice one big image to 32 images. It takes long time because i repeat the same commandline 32 times... So on my C code i load the photo into memory at once and divice into 32 image at once and save them at once... I dont repeat load image again and again...
But on nconvert batch i repeat the similar commandline 32 times. So 32 times load the BIG image. And It takes long time compate to my code...

cday
XnThusiast
Posts: 1768
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Slice One BIG photo into many small photos at once?

Post by cday » Sun May 06, 2018 7:35 am

You could use your C code to open formats that it can read, and NConvert once to convert other files to a format that it can read, so things aren't too bad?

Otherwise, have you looked at ImageMagick to check if it can output to multiple files?

Post Reply