Retrieve original transparency from a PNG

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
badabou
Posts: 54
Joined: 2008-06-23T06:12:24-07:00

Retrieve original transparency from a PNG

Post by badabou »

Hello,

I need your help experts.

I try to find the original transparency of a PNG image which has been replaced by an opaque color.


Here is an example :

The first image is the original image (with a nice gradual transparency) :
Image


The second is the image where there is no more transparency because the green (#00ff00) has replaced it.
Image


How to get the image 1 when I only have image 2 ? Is that possible with imagemagick ?

Thank you very much
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Retrieve original transparency from a PNG

Post by anthony »

This problem is one of the most basic problems I have, and one I have not yet solved.

Though I do try to make it easier on myself by having one image overlayed on black, and the other on white, Or at least any two colors that are reasonably separated. With the two different backgrounds a reasonable deduction of the alpha channel could be determined. With a reasonable alpha then the real color of the pixel should also be determinable. -- However I have not got a final solution for this!

However you only have ONE color! And with that, it is simply imposible to determine what is green, and what is transparent! Let alone how much green from each pixel was transparent!
Their is just not enough information for each pixel!

Really I have no good solution for this. As such I am very much open to suggestions.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply