Convert mode from RGBA to P should preserve transparency
Bug #381660 reported by
Stani
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Phatch |
Fix Released
|
High
|
Nadia Alramli |
Bug Description
When converting a RGBA image to a Palette image the transparency is not kept. This should be done by giving an index value to photo.info[
http://
Changed in phatch: | |
assignee: | nobody → Nadia Alramli (nadiana) |
importance: | Undecided → High |
status: | New → Confirmed |
Changed in phatch: | |
milestone: | none → 0.2.1 |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
$ bzr diff actions/ save.py' actions/ save.py 2009-05-29 13:40:01 +0000 actions/ save.py 2009-06-03 03:02:58 +0000 type(typ, TIF):
compression = self.get_ field(' TIFF Compression',info)
options[ 'compression. tif'] = compression type(typ, GIF) and not(info[ 'transparency' ] is None): 'transparency' ] = info['transpare ncy'] type(typ, GIF): Image.ADAPTIVE) ncy'] is None: 'transparency' ] = info['transpare ncy']
=== modified file 'phatch/
--- phatch/
+++ phatch/
@@ -114,8 +114,11 @@
elif self.is_
- elif self.is_
- options[
+ elif self.is_
+ photo.convert('P', palette=
+ info = photo.get_info()
+ if not info['transpare
+ options[
#save
photo. save(filename, **options)
=== modified file 'phatch/ core/pil. py' self,mode, *args,* *keyw):
"""Converts all layers to a different mode.""" values( ): convert( mode,*args, **keyw) split() [3] convert( 'RGB'). convert( 'transparency' ] = 255 convert( mode,*args, **keyw)
self. set_attr( _t('mode' ),mode)
--- phatch/core/pil.py 2009-05-29 16:56:48 +0000
+++ phatch/core/pil.py 2009-06-03 02:56:02 +0000
@@ -411,7 +411,17 @@
def convert(
for layer in self.layers.
- layer.image = layer.image.
+ if mode == 'P' and layer.image.mode == 'RGBA':
+ alpha = layer.image.
+ layer.image = layer.image.
+ mode, colors=255, *args, **keyw
+ )
+ layer.image.paste(
+ 255, Image.eval(alpha, lambda a: 255 if a <=128 else 0)
+ )
+ self.info[
+ else:
+ layer.image = layer.image.
def resize( self,size, method) :
$ bzr commit -m "fix gif transparency" sync/python/ phatch/ trunk/ actions/ save.py
Committing to: /home/stani/
modified phatch/
modified phatch/core/pil.py
Committed revision 626.