Page 1 of 1

Chopping images without gravity

Posted: 2016-05-31T13:32:20-07:00
by t94j0
Hello,
I have an array of (x,y) coordinate points in python and I would like to remove pixels that correspond to those coordinates. This is my first time using imageMagick, so I'm having some trouble. Right now, I'm using

Code: Select all

convert -chop 1x1+x+y input.png output.png
, but chop moves the image in a direction. Is there a way to chop and keep the part that was chopped transparent?

EDIT: I am using Version: ImageMagick 6.9.4-5 Q16 x86_64 on Mac.

Re: Chopping images without gravity

Posted: 2016-05-31T14:42:53-07:00
by fmw42
draw a singe tranparent pixel at the coordinates you want

Code: Select all

convert yourimage.suffix -fill none -draw "matte X,Y point" result.png
where x,y is the point to make transparent.

If you have a list of points, you can make a string or file (unix syntax)

Code: Select all

string="matte x1,y1 point matte x2,y2 point ... matte xN,yN point"
convert yourimage.suffix -fill none -draw "$string" result.png
textfile.txt is as below

matte x1,y1 point
matte x2,y2 point
...
matte xN,yN point

Code: Select all

cat textfile.txt | convert yourimage.suffix -fill none -draw "-" result.png

Re: Chopping images without gravity

Posted: 2016-06-01T06:21:58-07:00
by t94j0
That works perfectly, thanks!