Mask using polygon, then crop to known coordinates
Posted: 2017-08-29T18:07:00-07:00
A while back, I got some great help here understanding how to merge images.
I am on a simpler task now, which is to mask out pixels using a polygon, then crop that to a known rectangle.
I have this (runs as windows batch file) and it works, but does not crop as I did not tell it to yet:
"C:\Program Files\ImageMagick-7.0.5-Q8\magick.exe" ^
( "C:\Users\james\Desktop\Kir\granite.png" ^
( -size 128x128 xc:black -fill white -stroke white -draw "polygon 0,0 0,64 64,64 64,0" ) -alpha off -compose CopyOpacity -composite ^
) ^
-compose over -layers merge ^
"C:\Users\james\Desktop\Kir\Final.jpg"
I want to do this, but it does not work:
"C:\Program Files\ImageMagick-7.0.5-Q8\magick.exe" ^
( "C:\Users\james\Desktop\Kir\granite.png" ^
( -size 128x128 xc:black -fill white -stroke white -draw "polygon 0,0 0,64 64,64 64,0" ) -alpha off -compose CopyOpacity -composite ^
) ^
-compose over -layers merge ^
-crop 100x100+0+0 ^
"C:\Users\james\Desktop\Kir\Final.jpg"
I got close doing a couple other ways, but liked the merge method. Just not sure how to organize the code to crop it.
thanks
I am on a simpler task now, which is to mask out pixels using a polygon, then crop that to a known rectangle.
I have this (runs as windows batch file) and it works, but does not crop as I did not tell it to yet:
"C:\Program Files\ImageMagick-7.0.5-Q8\magick.exe" ^
( "C:\Users\james\Desktop\Kir\granite.png" ^
( -size 128x128 xc:black -fill white -stroke white -draw "polygon 0,0 0,64 64,64 64,0" ) -alpha off -compose CopyOpacity -composite ^
) ^
-compose over -layers merge ^
"C:\Users\james\Desktop\Kir\Final.jpg"
I want to do this, but it does not work:
"C:\Program Files\ImageMagick-7.0.5-Q8\magick.exe" ^
( "C:\Users\james\Desktop\Kir\granite.png" ^
( -size 128x128 xc:black -fill white -stroke white -draw "polygon 0,0 0,64 64,64 64,0" ) -alpha off -compose CopyOpacity -composite ^
) ^
-compose over -layers merge ^
-crop 100x100+0+0 ^
"C:\Users\james\Desktop\Kir\Final.jpg"
I got close doing a couple other ways, but liked the merge method. Just not sure how to organize the code to crop it.
thanks