Merge lp:~nadiana/phatch/bug_fix_487435 into lp:phatch

Proposed by Nadia Alramli on 2010-02-28
Status: Merged
Merge reported by: Stani
Merged at revision: not available
Proposed branch: lp:~nadiana/phatch/bug_fix_487435
Merge into: lp:phatch
Diff against target: 54 lines (+9/-7)
1 file modified
phatch/lib/imtools.py (+9/-7)
To merge this branch: bzr merge lp:~nadiana/phatch/bug_fix_487435
Reviewer Review Type Date Requested Status
Stani 2010-02-28 Approve on 2010-02-28
Review via email: mp+20311@code.launchpad.net
To post a comment you must log in.
Stani (stani) wrote :

Shouldn't this line:
del image.info['transparency']

be:
del img.info['transparency']

Is the same bug also not present in remove_alpha? I think functions which returns copies should not modify the original image, but maybe I've misunderstood something.

What is the reason that in put_alpha 1 and F images are converted to RGBA instead of LA? Is LA support broken in PIL? Just curious.

For the rest it seems good to me.

Thanks for your work!

review: Needs Information
lp:~nadiana/phatch/bug_fix_487435 updated on 2010-02-28
1647. By Nadia Alramli on 2010-02-28

Fixing stani suggestions

Nadia Alramli (nadiana) wrote :

You are right about del img vs del image so I fixed it. I also changed remove_alpha just in case
About the reason I'm converting to RGBA instead of LA. PIL's support to LA is broken or incomplete. Sometimes it works but mostly not. It's better to be safe and use RGBA in those cases.

Stani (stani) wrote :

Thanks, I merged it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phatch/lib/imtools.py'
2--- phatch/lib/imtools.py 2010-02-28 19:00:57 +0000
3+++ phatch/lib/imtools.py 2010-02-28 20:46:16 +0000
4@@ -271,7 +271,7 @@
5
6 .. see also:: :func:`reduce_opacity`
7 """
8- mark = open_image(mark)
9+ mark = convert_safe_mode(open_image(mark))
10 opacity /= 100.0
11 mark = reduce_opacity(mark, opacity)
12 layer = Image.new('RGBA', image_size, (0, 0, 0, 0))
13@@ -524,7 +524,7 @@
14 if has_alpha(image):
15 return image.split()[-1]
16 if image.mode == 'P' and 'transparency' in image.info:
17- return image.convert('LA').split()[-1]
18+ return image.convert('RGBA').split()[-1]
19 # No alpha layer, create one.
20 return Image.new('L', image.size, 255)
21
22@@ -666,7 +666,7 @@
23 if image.mode in ['CMYK', 'YCbCr', 'P']:
24 image = image.convert('RGBA')
25 elif image.mode in ['1', 'F']:
26- image = image.convert('LA')
27+ image = image.convert('RGBA')
28 image.putalpha(alpha)
29
30
31@@ -684,8 +684,9 @@
32 if image.mode == 'LA':
33 return image.convert('L')
34 if image.mode == 'P' and 'transparency' in image.info:
35- del image.info['transparency']
36- return image.convert('RGB')
37+ img = image.convert('RGB')
38+ del img.info['transparency']
39+ return img
40 return image
41
42
43@@ -804,8 +805,9 @@
44 if image.mode in ['1', 'F']:
45 return image.convert('L')
46 if image.mode == 'P' and 'transparency' in image.info:
47- del image.info['transparency']
48- return image.convert('RGBA')
49+ img = image.convert('RGBA')
50+ del img.info['transparency']
51+ return img
52 if image.mode in ['P', 'YCbCr', 'CMYK', 'RGBX']:
53 return image.convert('RGB')
54 return image

Subscribers

People subscribed via source and target branches

to status/vote changes: