Hi,
I'm exporting lots of PageItems to images using pageItem.export() method. I want the exported image to be a PNG if it contains transparent pixels, otherwise it should be a JPG.
So is there anyway to determine whether an exported PNG contains transparent pixels or not?
You might be able to check against a certain alpha channel. Not sure, but might be a decent starting point.
http://jongware.mit.edu/idcs4js/pc_ClippingPathSettings.html
You can try something like this.... This is in C# though, I'm sure the main methods that make this work aren't supported through javascript, but this might help you see how it is done in other languages.
Image img = Image.FromFile ( "...", true );
if ( (img.Flags & 0x2) != 0)
{
bool ContainsTransparent(Bitmap image)
{
for (int y = 0; y < image.Height; ++y)
{
for (int x = 0; x < image.Width; ++x)
{
if (image.getPixel(x, y).A != 255)
{
return true;
}
}
}
return false;
}
}
Hi all,
I just found out some great solutions to this problem, please have a look here http://stackoverflow.com/questions/13568717/check-if-a-png-image-conta ins-semi-transparent-pixel-using-as3/13570103
North America
Europe, Middle East and Africa
Asia Pacific