Opened 16 years ago

Closed 5 years ago

#2279 closed defect (wontfix)

GDAL doesn't handle the pre-multiplied alpha representation

Reported by: tamas Owned by: tamas
Priority: normal Milestone: closed_because_of_github_migration
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: alpha gtiff png
Cc: warmerdam

Description

Currently GDAL doesn't denote the alpha representation correctly (which is driver dependent) For example tiff uses premultiplied alpha representation by default (related to EXTRASAMPLE_ASSOCALPHA = 1) but png uses non premultiplied. I attach the png and the tif representetion of the same image, and the overlay with a white-gray hatch background using the pre-multiplied and non pre multiplied blending options.

Attachments (5)

alpha.png (231.7 KB ) - added by tamas 16 years ago.
pngsource_no_prempl.PNG (391.8 KB ) - added by tamas 16 years ago.
pngsource_prempl.PNG (385.3 KB ) - added by tamas 16 years ago.
tifsource_no_prempl.PNG (368.8 KB ) - added by tamas 16 years ago.
tifsource_prempl.PNG (393.0 KB ) - added by tamas 16 years ago.

Download all attachments as: .zip

Change History (11)

by tamas, 16 years ago

Attachment: alpha.png added

by tamas, 16 years ago

Attachment: pngsource_no_prempl.PNG added

by tamas, 16 years ago

Attachment: pngsource_prempl.PNG added

by tamas, 16 years ago

Attachment: tifsource_no_prempl.PNG added

by tamas, 16 years ago

Attachment: tifsource_prempl.PNG added

comment:1 by tamas, 16 years ago

Owner: changed from warmerdam to tamas

comment:2 by warmerdam, 16 years ago

Cc: warmerdam added
Keywords: alpha gtiff png added

comment:3 by warmerdam, 12 years ago

From an email discussion on gdal-dev including Tamas and Craig Bruce I wrote:

""" My opinion is that applications should assume alpha is not pre-multiplied. I have been hesitant to "un-premultiply" premultiplied TIFF images - partly because it is hard to hit all the appropriate code paths safely and partly because the result will be lossy.

Going forward GDAL should do one of two things:

1) provide a metadata item so applications can know those rare circumstances when alpha is pre-multiplied.

2) un-premultiply premultiplied alpha when encountered.

As you note it doesn't really matter when alpha is primarily used for on/off masking so we have gotten away over the years with only a few complaints about the topic. """

comment:4 by Jukka Rahkonen, 9 years ago

I believe that this is fixed in GDAL 1.10 and ticket can be closed but because I do not really understand the whole thing I'll wait for another opinion. From GeoTIFF driver page:

ALPHA=[YES/NON-PREMULTIPLIED/PREMULTIPLIED/UNSPECIFIED]: The first "extrasample" is marked as being alpha if there are any extra samples. This is necessary if you want to produce a greyscale TIFF file with an alpha band (for instance). For GDAL < 1.10, only the YES value is supported, and it is then assumed as being PREMULTIPLIED alpha (ASSOCALPHA in TIFF). Starting with GDAL 1.10, YES is an alias for NON-PREMULTIPLIED alpha, and the other values can be used.

comment:5 by Even Rouault, 9 years ago

GDAL now correctly set alpha in TIFF as non-premultiplied by default. It doesn't however do one of the 2 things suggested by Frank above.

comment:6 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.