Page 1 of 1
Crop with PNG on PNG [resolved]
Posted: 2016-09-14T19:38:13-07:00
by weblife
Anyone have a suggestion for how I can alter the following command to crop one PNG with another PNG?
Code: Select all
convert artwork.png alpha.png -gravity Center -alpha Off -compose copy_opacity -composite out.png
Currently the issue I am seeing is on my existing PNG image a black block appears where another PNG was placed to a transparent canvas.
+ =
My Version:
ImageMagick 6.9.1-10 Q16 x86_64 2015-07-26
Platform:
Mac OSX El Capitan 10.11.6
Re: Crop with PNG on PNG
Posted: 2016-09-14T19:41:53-07:00
by fmw42
What is your IM version and platform? Please always provide that.
Re: Crop with PNG on PNG
Posted: 2016-09-14T19:44:42-07:00
by weblife
Placed platform in above also. Sorry.
Re: Crop with PNG on PNG
Posted: 2016-09-14T19:49:42-07:00
by fmw42
try
Code: Select all
convert \( artwork.png -alpha extract \) alpha.png -gravity Center -alpha Off -compose copy_opacity -composite out.png
Is this what you want.
Your problem is that your artwork image has the detail in the alpha channel and not the base image. So you need to extract the detail from the alpha channel of artwork and use that.
Re: Crop with PNG on PNG
Posted: 2016-09-14T19:51:14-07:00
by fmw42
Or perhaps you want this with the polarity switched in the artwork texture.
Code: Select all
convert \( artwork.png -alpha extract -negate \) alpha.png -gravity Center -alpha Off -compose copy_opacity -composite out2.png
Re: Crop with PNG on PNG
Posted: 2016-09-14T20:15:04-07:00
by weblife
Thank you Fred. Much closer. The second output is closer to what I am looking to do "out2.png". I was able to achieve that with flatten :
Code: Select all
convert artwork.png -flatten alpha.png -gravity Center -alpha Off -compose copy_opacity -composite png:out.png
I want to keep the white area transparent also. Need to see if I alter my alpha.png white to transparent will achieve this.
Re: Crop with PNG on PNG
Posted: 2016-09-14T20:17:00-07:00
by weblife
I should clarify. I want to keep the transparent area transparent from "artwork.png".
Re: Crop with PNG on PNG
Posted: 2016-09-14T21:00:40-07:00
by fmw42
You will need to separate the alpha channels and then multiply them (possibly with one negated), then use the combined alpha channel and put that back on the image.
Note that transparent means the alpha channel will be black in those areas, not white.
Re: Crop with PNG on PNG
Posted: 2016-09-15T17:44:41-07:00
by weblife
Okay, here is what I did to achieve:
Code: Select all
convert \( artwork.png -gravity center -extent 2000x2000 -fuzz 9% -transparent white \) \
alpha.png -gravity center -alpha On -compose copy_opacity \
-composite -fuzz 9% -transparent white altered.png