Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
weblife
Posts: 21 Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151
Post
by weblife » 2016-09-14T19:38:13-07:00
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
Last edited by
weblife on 2016-09-15T17:45:02-07:00, edited 2 times in total.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2016-09-14T19:41:53-07:00
What is your IM version and platform? Please always provide that.
weblife
Posts: 21 Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151
Post
by weblife » 2016-09-14T19:44:42-07:00
Placed platform in above also. Sorry.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2016-09-14T19:49:42-07:00
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.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2016-09-14T19:51:14-07:00
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
weblife
Posts: 21 Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151
Post
by weblife » 2016-09-14T20:15:04-07:00
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.
weblife
Posts: 21 Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151
Post
by weblife » 2016-09-14T20:17:00-07:00
I should clarify. I want to keep the transparent area transparent from "artwork.png".
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2016-09-14T21:00:40-07:00
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.
weblife
Posts: 21 Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151
Post
by weblife » 2016-09-15T17:44:41-07:00
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