Merge lp://qastaging/~jochym/phatch/warm_up_action into lp://qastaging/phatch

Proposed by Paweł T. Jochym
Status: Merged
Merge reported by: Stani
Merged at revision: not available
Proposed branch: lp://qastaging/~jochym/phatch/warm_up_action
Merge into: lp://qastaging/phatch
Diff against target: 208 lines (+204/-0)
1 file modified
phatch/actions/warm_up.py (+204/-0)
To merge this branch: bzr merge lp://qastaging/~jochym/phatch/warm_up_action
Reviewer Review Type Date Requested Status
Stani Abstain
Review via email: mp+19402@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Paweł T. Jochym (jochym) wrote :

This is branch separated from Actions(parent) in the one-action-per-branch style.
This branch has only WarmUp action and all corrections/changes suggested by
Stani have been incorporated.

I think it is ready to consider for merging into the trunk.

Revision history for this message
Stani (stani) wrote :

Please remove this branch. It has been merged already.

review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'phatch/actions/warm_up.py'
2--- phatch/actions/warm_up.py 1970-01-01 00:00:00 +0000
3+++ phatch/actions/warm_up.py 2010-02-16 14:20:30 +0000
4@@ -0,0 +1,204 @@
5+# Phatch - Photo Batch Processor
6+# Copyright (C) 2007-2008 www.stani.be
7+#
8+# This program is free software: you can redistribute it and/or modify
9+# it under the terms of the GNU General Public License as published by
10+# the Free Software Foundation, either version 3 of the License, or
11+# (at your option) any later version.
12+#
13+# This program is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with this program. If not, see http://www.gnu.org/licenses/
20+#
21+# Phatch recommends SPE (http://pythonide.stani.be) for editing python files.
22+
23+# Embedded icon is designed by Igor Kekeljevic (http://www.admiror-ns.co.yu).
24+# Based on Stani's colorize
25+# This action is (C) 2010 by Pawel T. Jochym <jochym@gmail.com>
26+
27+# Make a colorized version of the image with midtone shifted to
28+# prescribed color value.
29+
30+from core import models
31+from core.translation import _t
32+
33+#---PIL
34+def init():
35+ global Image, ImageMath, ImageColor, imtools
36+ import Image, ImageMath, ImageColor
37+ from lib import imtools
38+
39+def warmup(image,midtone,brighten,amount=100):
40+ """Apply a toning filter. Move the midtones to the desired
41+ color while preserving blacks and whites with optional mixing
42+ with original image - amount: 0-100%"""
43+
44+ mode=image.mode
45+ info=image.info
46+
47+ if image.mode != 'L':
48+ im = imtools.convert(image,'L')
49+ else:
50+ im = image
51+
52+ if imtools.has_transparency(image):
53+ image = imtools.convert(image,'RGBA')
54+
55+ luma=imtools.convert(im.split()[0],'F')
56+ o=[]
57+ m=ImageColor.getrgb(midtone)
58+ b=brighten/600.0
59+ # Calculate channels separately
60+ for l in range(3):
61+ o.append(ImageMath.eval(
62+ "m*(255-i)*i+i",
63+ i=luma,
64+ m=4*((m[l]/255.0)-0.5+b)/255.0 ).convert('L'))
65+
66+ colorized = Image.merge('RGB', tuple(o) )
67+
68+ if imtools.has_alpha(image):
69+ imtools.put_alpha(colorized, image.split()[-1])
70+
71+ if amount < 100:
72+ colorized=imtools.blend(image, colorized, amount/100.0)
73+
74+ return colorized
75+
76+#---Phatch
77+class Action(models.Action):
78+ label = _t('Warm Up')
79+ author = 'Pawel T. Jochym'
80+ email = 'jochym@gmail.com'
81+ init = staticmethod(init)
82+ pil = staticmethod(warmup)
83+ version = '0.2'
84+ tags = [_t('filter'),_t('color')]
85+ __doc__ = _t('Warm up or colorize midtones of an image')
86+
87+ def interface(self,fields):
88+ fields[_t('Midtone')] = self.ColorField('#805d40')
89+ fields[_t('Brighten')] = self.SliderField(50,0,100)
90+ fields[_t('Amount')] = self.SliderField(50,1,100)
91+
92+ icon = \
93+'x\xda\x01p\x0b\x8f\xf4\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\
94+\x00\x000\x08\x06\x00\x00\x00W\x02\xf9\x87\x00\x00\x00\x04sBIT\x08\x08\x08\
95+\x08|\x08d\x88\x00\x00\x0b\'IDATh\x81\xd5\x99}\x8c\x9c\xc7]\xc7?3\xf3\xbc\
96+\xec\xcb\xbd\xda\xb7\xf7\xeas\xac\xe4\xe2:i\xac\x928mP\x9a\x94\xaa/$\xc4i*\
97+\x02\xe1\x0fT(\x12B\xa0\x12U\xc0\x1fH\xfcE\xfeF\x88\x7f\x88\x00\x81\x00\x11\
98+\x89R\x91\xa8\xa8\x8d\x94\xd4\x10\xd1\x04\x1a[\xads\x89\x82\x89]_\xec\xd4v.\
99+\xb6\xef\xf6\xeev\xf7nw\x9f\x97yf~\xfc\xb1\xe7\xf8JZ\xb8\xf3\xad\x83\x18ivfw\
100+\x9f\xe7\xf9}?\xf3\xfb\xfdffg\x95\x88\xf0\xff\xb9\x047\xf3\xe1\x9f~Y\x95\xb2\
101+\x8c\x83\n\xe2\x8aa\xe1\xa5\xcfI\xab\xdf6T?=p\xef\xbc\n\x83:_M\x12\x9eHR\x0e\
102+\xbb\x82J\x14\xc4h\x0c\x89\xed\xa2\ry\xa5\xc4\xf9r\x99o\x19\xc3\x9f\x1c\x7fH\
103+\x96wk\xb3o\x00\x0f|[}\xaa\xd9\xe6\x1f\xb4\xabN\x1f\x1a\xbd\x8b\xc9\xea>\xf6\
104+\xc4c\x94\x83*\x08d.\xa5\x91\xad\xb2\xd4\xbd\xca\x99\xd5\xff\xa0\xe3\x1b\x9d\
105+\xb1\x1a\xbfw\xfc\xf3\xf2\x97\xff\xa7\x00\xea)\xa5?~\x1f\x7f\x9e\xac\xc7\xbf\
106+\xfe\xb1\xb1\x8f\x9b[\x87?B)(\x11\xe8\x90HG\x04&\x04\x01\xeb-\xd6Yr\x97\x93;\
107+\xcb\xc5\xf5wxc\xe9\xfb\x98\x81\xf5WB\xc7/|\xff\xe7e\xf5C\x07\xb8\xff\x98\
108+\x1aow\xf8\x9e\xb3\xe1\x81\x07f>K\xad<Al"B\x1d\x12\x06!\xa1\x0e1\x9biVH\xb1\
109+\t`\xb1\x85%s9\x1b\xf9\x06\xaf\xbc\xf7/d~c}\xef^\xbex\xfcg\xe5\xe5\x9dj\xd07\
110+\xac\x1eH3\x9e\xb3\x96\x03\xf7N\xfc4#\xa5a\xb4v\xa0\x0b\x08,\xa2r\x9cJ)T\x17\
111+\xab\xba8\x95\xe2u\x0e\xda"\xc6\x82v\xc4a\xc8}\x13\x0f\x80\x84C\x8d&_\x7f\
112+\xe4E\x15\x7fh\x00\x9f|I\xfdV\xb7\xc3\x83\x83q\x95\xd1\xd2\x08\xa2,^\xe7x\
113+\x9d\xe1U\x867)N%\x14\xaa\x8bS\xdd^K\x82\xd3i\xef{\x95\xe1UN\x18\x1a\xc6+5\
114+\xb2\x94\x89\xe5\x82g>\x14\x80O\x7fGM4\x9b\xfc\x91\t`Oe\x0f^\xf7F\xdc\xab\
115+\x0c\xaf3\x9cNz\xe2u\x17\xa7\xbb\x14\xba\x8b7\xc9\xfb\x9f{\x95\xe1T\x86#\xc3\
116+\x933Z\x1eEkX[\xe3\x17\xef?\xa6\x1e\xd9\x89\x96\x1bZ\x076\xba|\xcd;\x06\xa3\
117+\x08\xfc\xa6p\xa7\x0b\xb42\x18mpZ\xa3\xb4F+\x85\xa0\xf0"\x88@\xa1=N<\x85\xf2\
118+8\xe5p\xaa\xc0\xe1pd\x18\x03\xde\xa3\x1b-\xfe\x06\x98\xdc\xae\x96\x1d{\xe0\
119+\x91\x17U\xdci\xf3I\xadA+h\x17k\x14\xa4\x14*\xc5\xe9\x94B%x\x95\xe0t\x17g\
120+\xba\xf8\xa0W\x9d\xde\x0c%\x12\n\x95\xf4ZI)Hi\x15+\x98\xcd\xe7\xa5\t\x13\x0f\
121+\xfe\xb3\xfa\xdcv\xf5\xec\xd8\x03\xcd\x80/\x8b\'\xd6\x06\xb4\x06\xd1\x96\xd5\
122+\xfc=jA\r\x83A+\x8d2\xaa\xa7\xc6(@\xe1D\xf0\x02\xce\x0bVy\xacx,\x9e\\\x1c\
123+\x1b\xaeM\xd7\xb6P\xba\xf7<\xe7!I\xf9\r\xe0\xa5\x9b\x02`\xf3\xde\xe8\x0fU4b\
124+\x04\x94P\xcf/\x11F\x9e\xd1p\x04D\xa3D\xa3\x8dB\x1bp\n\xc4\xf7\x84Y%\x14\xca\
125+c\x95`\xbd\xa7\xe3\xba\\N/\x82\x16\xb4\x02\xb5\x19\x0fy\xc1G\xb7\xabg\xc7\
126+\x00\xce3e\x14\x8cT\xca\x94#\xc3Z\xba\x81ha\xd5-\xe2\xec\x06\xa3\xc1(\xa8\
127+\x08\xbc\x82\x00L\x00\xd6\x82U`\x11r/\xa4\xbe\xa0Q4i\xe6-D<\n\xe8\xbd\xf4JQ0\
128+z\xd3\x00\x10\xaa\x02T\x82\x12\x93\x03{\x18(E\\\\_\xa1\xb5\x04i\xa9\x85\x9dj\
129+1\xa0+T\x88\x89\x8a\x80\xd6e\xc5\xa9\x93]\xee\xfb|\x85\xb4\xb0$E\xceF\xda%\
130+\xb3\xc2\xd2y\x18\x98\xdc\x14\xbfe=\xf5Bi\xbbrv\x9c\xc4A\xc0\xeb\x85\xeb\xf5\
131+k\xf1\x14\xb7\x0e\x1edj`\x88\xcbo\xc3\xc9\xe7ac\r\xba\xb6K+op\xe9j\x9d\x7fzf\
132+\x99\x8b?l\xf3\xf2\xb1e\xd6\xb3\x06]\xdb\xc1y\xe1\x9d\xd7\xe0\x07\xdf\x05\
133+\xefz!&\xf4Z\x80R\xcc\xdb\xdb\xd6\xb3S\x80\xd0\xf0\xbc\x08O&6\xa7\xa4\xab\
134+\xccV\xe7($\xe3\xed\xd9\xd7Y>/\xbc\xfa\x1c\xec\xbb\xa3\x97\xc3\x8bg\xe1\xa7>\
135+\x03\xb5[\xe0{\xcf\xc3+_\x87\xda\x01\xa8_\x84N\x13\x06k\xa0\x03(,x\x0f~\xd3\
136+\x0bQ\xcc\xbfmW\xcf\x8e=p\xfc\x04/)E\xbe\xd2Nh\x17mf\xca\x87\xb9c\xe8~\x0e\
137+\xdf6\x8e\x00\x9f\xf8"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93\xb5\x1a\xbf{\xfa\xca\x92\x9c]9\xc7Z\xa7\xc5\xe8\xb8\xa1\
152+ueK\x08\xa5\x90\xa5\x9b\xfd\x02ZW{\xe2\x8f\x1e\xba\x97\xa3\xd3O\xf2\x8d3\xdf\
153+fl\x94\xbf\xbf\xd1\xdf\xc6\xbb\x02\x008\xfe\xb0\xfcYy\xd0\x7f\xed\xed\x95e.\
154+\xaf\xafR\x1a\x85\xf6\xeaf\x12o\x89\xff\xcc\xf6 \xda\xcb0=\x1bR+\xed\xe3\x97\
155+_|\x94R\xc5\xff\xe7\xc9/\xc8\xaf\xdc\xa8\xfd]\x03\x00\xbc\xf6\xa8|\xc9\xe9\
156+\xe2\x07\xef6\xdb\xe4A\x81\xcb\xa0\xc8z\x8b\x93\xf3\xbd\xf6\xda*\xdb]\x81\
157+\xd1\xc9\x80\xbf}\xe3\x9b8U\xac\x0fT\xf9\xecnl\xf7\x05\x00\xa0Z\xe1\xefr+dV(\
158+\x8d@\xda\xf8\xe05\xb6\x03\xda@=Mp^\xa8V\xf9\xeen\xcf\x86\xfa\x06\x10Vx\xeeZ\
159+\xbf\xb4\x07\x92\x1f\x03\xd0]\x85\xf2\xd8\xf5\xf7q\xc4\xbf\xee\xd6n\xdf\x00\
160+\xfe\xfdg\xe4\x9c\xd6X\x80x\x04\x92U\xe8vac\x03\xd67z\xfd\xce2\xc4[6\xca\x06\
161+^\xdf\xad\xdd\xbe\x9e\x8d\x96c\xd3\\m\xb8Z}\x19\\\x0c\xcbK\\\xdf\xe7\x0b\xe0\
162+\xa1\xde\x82=\x01\x8c\x0c+\xa7*rf\xb76\xfb\n\xf0\x95\xf4\x8fK\xc7\xf6\xfe\
163+\x15o\xe9\x8b\xac\x0e$d\xd6\xe3\x8a\x9e\xf6 \x80\xf06\xc5@\x14p\xcb\xc0\x08\
164+\x07\xcf>h&\xdf\xba}?\x9f\xe2\xeanl\xf6\x15`H\x8f\xc9\x97\xe4)\xd6\xf5:\xae\
165+\xeaX/\xd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f|\xf2\x13\xadV\xeb3\xde\xfb\xb1R\xa9t\xfc\xe8\xd1\xa3\xc7\x1e\
180+\x7f\xfc\xf1\xce\xd6kj\xb5\x9a\x00\xec\xdb\xb7O\x00\xe6\xe6\xe6d~~^\xdey\xe7\
181+\x1d\xff\xc4\x13Ol\x9ds\x7f\xac\xd0\xff\r@\xd1\x0b3}\xee\xdc9\x1d\x04\x81ZXX\
182+0\xf5z\xdd\xd4\xebu-"z}}]\xb7\xdbm\xad\x94\xd2\xd6Z\x95\xa6\xa9.\x8aB9\xe7\
183+\x94s\xeeG\x80\x8c1\x02\x10\xc7\xb1\x0f\x82@\x82 \x90J\xa5\xe2E\xc4\x0f\x0e\
184+\x0e\xfa\x91\x91\x11o\x8c\xf1\x07\x0f\x1etq\x1c\xbbZ\xad\xe6\xf3<\x97;\xef\
185+\xbc\xd3\x03~\x13\xe2G\x04\xffO\xb3\x90\x9a\x9f\x9f\x0f\xf6\xee\xddk.\\\xb8\
186+\x10$I\xa2\xdf|\xf3Ms\xe6\xcc\x19}\xf5\xeaU\xd3\xe9t\x82n\xb7\x1bZk\x83<\xcf\
187+C\xe7\\p\xad\x8a\x88\xf1\xde\x9b \x08\x94\x88\xbc\x9fgJ)_\x14\x85h\xad\x9d\
188+\xd6\xba\xd0Z;cLa\x8c)\xa2(\xb2q\x1c\xdbR\xa9T\x8c\x8f\x8f\x17\x87\x0e\x1dr\
189+\xb3\xb3\xb3\xfe\xc0\x81\x03\xae(\nW\xa9T\x8a\xb9\xb99\xbb]\x00\x05\xe8#G\
190+\x8e\x98\xb3g\xcf\x86\x0b\x0b\x0b\xfa\xd5W_\r.]\xba\x14...\x06\xf5z=L\x92$\
191+\x06"\x11\x89E$\x06b\x11\x89\x80\x08\x08\xb7T\xc3\xf5\xf3g\x07\x14\x9b5\x07r\
192+\xa5T\x0ed\xd7\xda8\x8e\xb3J\xa5\x92_\xbat\xc9\x8e\x8d\x8d\xd9\xbb\xee\xba\
193+\xcb\xdes\xcf=nzzZ\xcd\xcd\xcd}\xc0\x0b?i\x16\x92g\x9f}\x96\x0b\x17.\x00\xb0\
194+\xb6\xb6\xa6\x93$\xd1Y\x96\x19cL\x18\x04\xc15\xf1%\x11)\x01e\x11)\x03U`\x00\
195+\x18\x14\x91!\x11\x19\x16\x91\x11\x11\xd9\xb3YGEd\x18\x18\x02\x06\x81\x01\
196+\x11\xa9\x02U\x11)\x8bH\xd9{_\xd6Z\x97\xd24\x8d:\x9dN\xb8\xba\xba\x1a4\x1a\r\
197+\r0??\xff\x01\xa1?1\x846\x13\xa88q\xe2\x84\x9a\x9d\x9dUq\x1c\xab\x8b\x17/\
198+\x16\x0b\x0b\x0bjxx\x98V\xab%\xd6Z)\x8a\xc29\xe7\n\xe7\\\xee\xbd\xcf\xbc\xf7\
199+\x91\x88D"\x12\x8aH "\xc1\xe6@\x89R\xca)\xa5,Ph\xads\xa5\x94\xd5Z\xe7\xc6\
200+\x98\\k\x9d\x07A\x90W\xab\xd5|``\xc0\x8e\x8f\x8f\xe7SSSv\xef\xde\xbd\xb6\\.\
201+\xe7\xfb\xf6\xed\xb3sss\x8e\x1d\xe4\x80\x00nqqQ\xa2(rw\xdf}\xb7v\xce\x99\xd1\
202+\xd1QS\xaf\xd7C\xe7\x9ci6\x9bA\x92$&\xcb2\x93\xa6i\xa0\x942y\x9e\x07EQ\x18\
203+\xe7\x9cq\xce\x19\xef\xbd\x16\x11\xa5\x94\x12\xad\xb5\xd7Z{c\x8c\x0b\x82\xc0\
204+\x05A\xe0\x80"\x8a"\x17E\x91\xabV\xabE\xb5Zu\xde{;<<l\xf7\xef\xdf\xef\xc6\
205+\xc6\xc6\xdc\xe1\xc3\x87\xdd\xdc\xdc\x9cSJ\xc9\x7f\x9ft\xfe\x0b\xa6&\x926\
206+\xd8\x8d\xfa\xa5\x00\x00\x00\x00IEND\xaeB`\x82\xb6>\x9f:'
207+
208+

Subscribers

People subscribed via source and target branches

to status/vote changes: