phatch-dev team mailing list archive
-
phatch-dev team
-
Mailing list archive
-
Message #01071
[Merge] lp:~jochym/phatch/pep8 into lp:phatch
Paweł T. Jochym has proposed merging lp:~jochym/phatch/pep8 into lp:phatch.
Requested reviews:
stani (stani)
PEP8 compliance for warm_up and grid actions.
Both pass pep8.py test.
Stani's copyrights added as appropriate.
--
https://code.launchpad.net/~jochym/phatch/pep8/+merge/20276
Your team Phatch Developers is subscribed to branch lp:phatch.
=== modified file 'phatch/actions/grid.py'
--- phatch/actions/grid.py 2010-02-24 21:00:07 +0000
+++ phatch/actions/grid.py 2010-02-27 17:23:15 +0000
@@ -16,15 +16,19 @@
# Embedded icon is designed by Igor Kekeljevic (http://www.admiror-ns.co.yu).
# Based on standard Stani's actions
-# This action is (C) 2010 by Pawel T. Jochym <jochym@xxxxxxxxx>
+# Copyright (C) 2007-2008 www.stani.be
+# Copyright (C) 2010 by Pawel T. Jochym <jochym@xxxxxxxxx>
# Make m x n grid with copies of imput image
+# Follows PEP8
+
from core import models
from core.translation import _t
from lib.imtools import has_transparency
from math import sqrt
+
#---PIL
def init():
global Image
@@ -32,20 +36,21 @@
global HTMLColorToRGBA
from lib.colors import HTMLColorToRGBA
-def make_grid(image,grid,background_colour,old_size=None,scale=True):
+
+def make_grid(image, grid, background_colour, old_size=None, scale=True):
#check if there is any work to do
if grid[0] == 1 and grid[1] == 1:
return image
#because of layer support photo size can be different from image layer size
if old_size is None:
- old_size = image.size
- if scale :
+ old_size = image.size
+ if scale:
# Keep the same number of pixels in the result
- s=sqrt(grid[0]*grid[1])
- old_size = tuple(map(lambda x: int(x / s) , old_size))
- image=image.resize( old_size, getattr(Image,'ANTIALIAS'))
+ s = sqrt(grid[0] * grid[1])
+ old_size = tuple(map(lambda x: int(x / s), old_size))
+ image = image.resize(old_size, getattr(Image, 'ANTIALIAS'))
- new_size=grid[0] * old_size[0], grid[1] * old_size[1]
+ new_size = grid[0] * old_size[0], grid[1] * old_size[1]
#displacement
dx, dy = old_size
@@ -55,50 +60,49 @@
if has_transparency(image) and image.mode != 'RGBA':
# Make sure 'LA' and 'P' with trasparency are handled
image = image.convert('RGBA')
- else :
+ else:
image = image.convert('RGB')
- new_canvas = Image.new(image.mode,new_size,background_colour)
+ new_canvas = Image.new(image.mode, new_size, background_colour)
for x in range(n):
for y in range(m):
- new_canvas.paste(image,(x*dx,y*dy))
-
+ new_canvas.paste(image, (x * dx, y * dy))
return new_canvas
#---Phatch
class Action(models.Action):
- label = _t('Grid')
- all_layers = True
- author = 'Pawel T. Jochym'
- email = 'jochym@xxxxxxxxx'
- init = staticmethod(init)
- pil = staticmethod(make_grid)
- version = '0.2'
- tags = [_t('size'),_t('filter')]
+ label = _t('Grid')
+ all_layers = True
+ author = 'Pawel T. Jochym'
+ email = 'jochym@xxxxxxxxx'
+ init = staticmethod(init)
+ pil = staticmethod(make_grid)
+ version = '0.2'
+ tags = [_t('size'), _t('filter')]
update_size = True
- __doc__ = _t('Make n x m grid of image')
-
- def interface(self,fields):
- fields[_t('Width')] = self.SliderField(1,1,8)
- fields[_t('Height')] = self.SliderField(1,1,8)
- fields[_t('Background Color')] = self.ColorField('#FFFFFF')
- fields[_t('Scale to keep size')] = self.BooleanField(True)
-
- def values(self,info):
+ __doc__ = _t('Make n x m grid of image')
+
+ def interface(self, fields):
+ fields[_t('Width')] = self.SliderField(1, 1, 8)
+ fields[_t('Height')] = self.SliderField(1, 1, 8)
+ fields[_t('Background Color')] = self.ColorField('#FFFFFF')
+ fields[_t('Scale to keep size')] = self.BooleanField(True)
+
+ def values(self, info):
#size
- x0, y0 = info['size']
- x1 = self.get_field('Width',info)
- y1 = self.get_field('Height',info)
- grid = x1,y1
+ x0, y0 = info['size']
+ x1 = self.get_field('Width', info)
+ y1 = self.get_field('Height', info)
+ grid = x1, y1
#parameters
return {
- 'old_size' : (x0,y0),
- 'grid' : grid,
- 'background_colour' : self.get_field('Background Color', info),
- 'scale' : self.get_field('Scale to keep size', info),
+ 'old_size': (x0, y0),
+ 'grid': grid,
+ 'background_colour': self.get_field('Background Color', info),
+ 'scale': self.get_field('Scale to keep size', info),
}
icon = \
=== modified file 'phatch/actions/warm_up.py'
--- phatch/actions/warm_up.py 2010-02-24 21:00:07 +0000
+++ phatch/actions/warm_up.py 2010-02-27 17:23:15 +0000
@@ -10,7 +10,7 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/
#
@@ -18,72 +18,80 @@
# Embedded icon is designed by Igor Kekeljevic (http://www.admiror-ns.co.yu).
# Based on Stani's colorize
-# This action is (C) 2010 by Pawel T. Jochym <jochym@xxxxxxxxx>
-
-# Make a colorized version of the image with midtone shifted to
-# prescribed color value.
+# Copyright (C) 2007-2008 www.stani.be
+# Copyright (C) 2010 by Pawel T. Jochym <jochym@xxxxxxxxx>
+
+# Make a colorized version of the image with midtone shifted to
+# prescribed color value.
+
+# Follows PEP8
from core import models
from core.translation import _t
+
#---PIL
def init():
global Image, ImageMath, ImageColor, imtools
- import Image, ImageMath, ImageColor
- from lib import imtools
-
-def warmup(image,midtone,brighten,amount=100):
+ import Image
+ import ImageMath
+ import ImageColor
+ from lib import imtool
+
+
+def warmup(image, midtone, brighten, amount=100):
"""Apply a toning filter. Move the midtones to the desired
- color while preserving blacks and whites with optional mixing
+ color while preserving blacks and whites with optional mixing
with original image - amount: 0-100%"""
-
- mode=image.mode
- info=image.info
-
+
+ mode = image.mode
+ info = image.info
+
if image.mode != 'L':
- im = imtools.convert(image,'L')
+ im = imtools.convert(image, 'L')
else:
im = image
if imtools.has_transparency(image):
- image = imtools.convert(image,'RGBA')
-
- luma=imtools.convert(im.split()[0],'F')
+ image = imtools.convert(image, 'RGBA')
+
+ luma = imtools.convert(im.split()[0], 'F')
o = []
m = ImageColor.getrgb(midtone)
b = brighten / 600.0
# Calculate channels separately
for l in range(3):
o.append(ImageMath.eval(
- "m*(255-i)*i+i",
- i=luma,
- m=4*((m[l]/255.0)-0.5+b)/255.0 ).convert('L'))
-
- colorized = Image.merge('RGB', tuple(o) )
-
+ "m*(255-i)*i+i",
+ i=luma,
+ m=4 * ((m[l] / 255.0) - 0.5 + b) / 255.0).convert('L'))
+
+ colorized = Image.merge('RGB', tuple(o))
+
if imtools.has_alpha(image):
imtools.put_alpha(colorized, image.split()[-1])
if amount < 100:
- colorized=imtools.blend(image, colorized, amount/100.0)
-
+ colorized = imtools.blend(image, colorized, amount / 100.0)
+
return colorized
+
#---Phatch
class Action(models.Action):
- label = _t('Warm Up')
- author = 'Pawel T. Jochym'
- email = 'jochym@xxxxxxxxx'
- init = staticmethod(init)
- pil = staticmethod(warmup)
- version = '0.2'
- tags = [_t('filter'),_t('color')]
- __doc__ = _t('Warm up or colorize midtones of an image')
-
- def interface(self,fields):
- fields[_t('Midtone')] = self.ColorField('#805d40')
- fields[_t('Brighten')] = self.SliderField(50,0,100)
- fields[_t('Amount')] = self.SliderField(50,1,100)
+ label = _t('Warm Up')
+ author = 'Pawel T. Jochym'
+ email = 'jochym@xxxxxxxxx'
+ init = staticmethod(init)
+ pil = staticmethod(warmup)
+ version = '0.2'
+ tags = [_t('filter'), _t('color')]
+ __doc__ = _t('Warm up or colorize midtones of an image')
+
+ def interface(self, fields):
+ fields[_t('Midtone')] = self.ColorField('#805d40')
+ fields[_t('Brighten')] = self.SliderField(50, 0, 100)
+ fields[_t('Amount')] = self.SliderField(50, 1, 100)
icon = \
'x\xda\x01<\n\xc3\xf5\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\
Follow ups