Capturing multipe file with convert output to STDOUT
Posted: 2010-03-31T18:30:33-07:00
First some background - I have an image (image.tif) in PTIF format that I got with the command:
When I run "identify" on the resulting file, I get the following:
All good so far, now if I want to get the 256x256 tiles from layer 3, I can do:
... which will give me the following tile files:
Now, my question: I am writing a java program that needs to spawn a process executing the convert command to do exactly what I did in the command above. I will be feeding that process the PTIF data via STDIN and want to capture the multiple tile files by capturing the process' STDOUT. The command I issue in the java process:
When I run the command what I get back in STDOUT is just a bunch of bytes. Basically, all of the tiles combined serially into one stream of bytes. I need to know, what delimiter bytes I need to look for to see that one tile has ended and another has started. Any help would be appreciated.
Code: Select all
convert image.jpg ptif:image.tif[256x256]
Code: Select all
image.tif[0] TIFF 2826x4256 2826x4256+0+0 8-bit DirectClass 7.555MB 0.000u 0:00.001
image.tif[1] TIFF 1413x2128 1413x2128+0+0 8-bit DirectClass 7.555MB 0.016u 0:00.012
image.tif[2] TIFF 706x1064 706x1064+0+0 8-bit DirectClass 7.555MB 0.016u 0:00.022
image.tif[3] TIFF 353x532 353x532+0+0 8-bit DirectClass 7.555MB 0.016u 0:00.031
image.tif[4] TIFF 176x266 176x266+0+0 8-bit DirectClass 7.555MB 0.016u 0:00.043
image.tif[5] TIFF 88x133 88x133+0+0 8-bit DirectClass 7.555MB 0.016u 0:00.051
image.tif[6] TIFF 44x66 44x66+0+0 8-bit DirectClass 7.555MB 0.016u 0:00.059
Code: Select all
convert image.tif[3] -crop 256x256 tile-%02d.jpg
Code: Select all
-rw-rw-rw- 1 user group 17587 Mar 31 21:13 tile-03.jpg
-rw-rw-rw- 1 user group 7631 Mar 31 21:13 tile-04.jpg
-rw-rw-rw- 1 user group 27854 Mar 31 21:13 tile-05.jpg
-rw-rw-rw- 1 user group 13476 Mar 31 21:13 tile-06.jpg
-rw-rw-rw- 1 user group 3975 Mar 31 21:13 tile-07.jpg
-rw-rw-rw- 1 user group 1810 Mar 31 21:13 tile-08.jpg
Code: Select all
/PATH_TO_CONVERT/convert -[3] -crop 256x256 jpg:-