Problems ripping png alpha channel

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?".
Post Reply
auror

Problems ripping png alpha channel

Post by auror »

Attempting to get a black and white image of the png alpha channel with this command:

Code: Select all

convert *.png -channel alpha -negate -separate *.png
Produces copies of the original converted images, which I don't want.
I need a solution for this.
Windows, so all solutions must work on it.
I have already tried all of these too:
http://www.imagemagick.org/Usage/channels/#extract
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problems ripping png alpha channel

Post by anthony »

You can NOT use '*' in a destination image filename!!!!
Only a single filename can be used for the output of convert with and optional %d printf formating for a number when outputting a multiple image sequence as separate files!

That a '*' would expands to the original list of images, only the last of which is used as the save file. As PNG can not save multiple images per file, ALL the images would have been saved as last_file-{number}.png, which is obviously NOT want you want.

See mogify for a command that will process and save images back to the same filename, or to difference format suffix, or different directory.

DANGER DANGER --- mogrify can destroy the original image, caution and testing with a copy of the images is recommended.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
auror

Re: Problems ripping png alpha channel

Post by auror »

Thanks for the tip, it works great!
Here is the new command:

Code: Select all

mogrify -format png -path pathnamehere -channel alpha -negate -separate *.png
One question though, how do I output to a path that contains a space? I have tried putting a / before the space and even replacing it with %20!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problems ripping png alpha channel

Post by anthony »

quote the argument. It isn't IM that is giving you the trouble here, but the Wrapping Shell (or DOS) command line environment.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply