Reputation: 2298
I want to crop an image (area1), then make white a particular sub area(area2) of the cropped image and finally make the background transparent.
I'm able to get my desired output in the following 3 separate commands.
convert input.jpg -crop 908x391+21+545 out1.jpg 'crop image (area1)
convert out1.jpg -fuzz 100% -fill '#ffffff' -region 908x28+4+33 -opaque white out2.jpg 'make blank particular region (area2)
convert out2.jpg -bordercolor "#0019ff" -border 4x4 -transparent white output.png 'make all white background transparent
But when I try to join the 3 commands in a single one like below, in the output the area2 still appears and background is not transparent.
convert input.jpg -crop 908x391+21+545 -fuzz 100% -fill '#ffffff' -bordercolor "#0019ff" -border 4x4 -region 908x28+25+578 -transparent white output.png
How can I make this in a single command? Thanks
Update
convert input.jpg \
\( -clone 0 -crop 908x391+21+545 +repage -region 908x28+4+33 -fill white \
-colorize 100 +region -resize 908x681! -bordercolor "#f019ff" -border 4x4 \
-repage 1842x689+0+0 \) \
\
\( -clone 0 -crop 908x391+21+4444 +repage -region 908x28+4+33 -fill white \
-colorize 100 +region -resize 908x681! -bordercolor "#f019ff" -border 4x4 \
-repage 1842x689+926+0 \) \
-delete 0 -flatten -resize 1180 -transparent white OOUUTT.png
Upvotes: 0
Views: 939
Reputation: 53089
In Imagemagick 6, try this (if Imagemagick 7 replace convert with magick), using new line \ to make it more readable.
convert input.jpg -crop 908x391+21+545 +repage \
-region 908x28+4+33 -fill white -colorize 100 +region \
-bordercolor "#0019ff" -border 4x4 -transparent white \
output.png
Or as one long command line:
convert input.jpg -crop 908x391+21+545 +repage -region 908x28+4+33 -fill white -colorize 100 +region -bordercolor "#0019ff" -border 4x4 -transparent white output.png
For example using a gradient input:
convert -size 1500x1500 gradient: -crop 908x391+21+545 +repage -region 908x28+4+33 -fill white -colorize 100 +region -bordercolor "#0019ff" -border 4x4 -transparent white output.png
Or alternately compositing a transparent region over your cropped image:
convert -size 1500x1500 gradient: -crop 908x391+21+545 +repage \
\( -size 908x28 xc:none \) \
-alpha on -channel rgba -geometry +4+33 -compose copy -composite \
output2.png
Upvotes: 1