How to use subshell to crop several coordinates in a single process
Posted: 2018-10-25T09:29:04-07:00
Hello to all,
I have these coordinates and the input image below.
coords="110x16+255+175
178x59+29+65
178x59+223+65
178x59+417+65
178x59+611+65
240x151+462+176
240x151+87+257
240x151+366+355
240x151+77+448
240x151+468+542
240x151+140+624"
areas.png
For the first 5 coordinates I apply this code (images 0 to 4):
And for the rest of coordinates (5 to 10), I want to apply the convert command below in consecutive pairs, this is join coordinate 5 with 6, 7 with 8 and 9 with 10.
But it seems I cannot use the first subshell code where was stored the frames in miff memory for the rest of the coordinates.
So, when I run these 3 command failed.
Do I need to do a subshell for each pair of coordinates or how to mix in a single process the operations for all the coordinates?
The outputs would be like this:
ImgHeader.png
ImgTop.png
ImgMiddle.png
ImgBottom.png
LeftRight.png (This is only a helper image to use it to put the header over each resulting image)
Thanks in advance for any help.
I have these coordinates and the input image below.
coords="110x16+255+175
178x59+29+65
178x59+223+65
178x59+417+65
178x59+611+65
240x151+462+176
240x151+87+257
240x151+366+355
240x151+77+448
240x151+468+542
240x151+140+624"
areas.png
For the first 5 coordinates I apply this code (images 0 to 4):
Code: Select all
(
for coord in $coords; do
echo >&2 "$coord"
convert areas2.png +repage -crop $coord +repage -bordercolor black -border 2x2 miff:-
done
) | \
convert - -write mpr:img -delete 0--1 \( mpr:img[1,2] -smush -2 \) \( mpr:img[3,4] -smush -2 \) \
+smush -2 mpr:img[0] +swap -gravity center -background none -smush +3 ImgHeader.png
But it seems I cannot use the first subshell code where was stored the frames in miff memory for the rest of the coordinates.
So, when I run these 3 command failed.
Code: Select all
convert - -write mpr:img -delete 0--1 \( mpr:img[5,6] +smush +6 \) \
+smush -2 LeftRight.png +swap -gravity center -background none -smush +3 ImgTop.png
convert - -write mpr:img -delete 0--1 \( mpr:img[7,8] +smush +6 \)\
+smush -2 LeftRight.png +swap -gravity center -background none -smush +3 ImgMiddle.png
convert - -write mpr:img -delete 0--1 \( mpr:img[9,10] +smush +6 \) \
+smush -2 LeftRight.png +swap -gravity center -background none -smush +3 ImgBottom.png
The outputs would be like this:
ImgHeader.png
ImgTop.png
ImgMiddle.png
ImgBottom.png
LeftRight.png (This is only a helper image to use it to put the header over each resulting image)
Thanks in advance for any help.