~ubuntu-branches/ubuntu/lucid/phatch/lucid

« back to all changes in this revision

Viewing changes to phatch/actions/rank.py

  • Committer: Package Import Robot
  • Author(s): Emilio Pozuelo Monfort, Stani M, Emilio Pozuelo Monfort
  • Date: 2010-03-12 14:04:02 UTC
  • mfrom: (1.1.11) (4.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20100312140402-o6g6terpbqksf1dw
Tags: 0.2.7-1
[ Stani M ]
* Upstream bugfix release (Closes LP: #472978, #487435, #516763, #516858, 
  #525999, #526047, #526235, #526237, #526489, #529343, #529429, #525831, 
  #526237, #529544, #529605, #531375, #531705, #531728, #532346, #532356, 
  #532540, #532544, #533068, #534723, #534834, #534835, #535189, #535192,
  #536820)
* debian/control: Add python-nautilus to phatch-nautilus's Depends

[ Emilio Pozuelo Monfort ]
* debian/rules:
  - Adapt for the upstream changes.
* debian/copyright:
  - Updated for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
# Embedded icon is taken from www.openclipart.org (public domain)
20
20
 
 
21
# Follows PEP8
 
22
 
21
23
from core import models
22
24
from lib.reverse_translation import _t
23
25
 
24
26
#---PIL
 
27
 
 
28
 
25
29
def init():
26
30
    global Image, ImageFilter, imtools
27
 
    import Image, ImageFilter
 
31
    import Image
 
32
    import ImageFilter
28
33
    from lib import imtools
29
34
 
30
 
def rnk(image,radius,rank=50,amount=100):
 
35
 
 
36
def rnk(image, radius, rank=50, amount=100):
31
37
    """Apply a filter
32
38
    - amount: 0-1"""
33
 
    rank     /= 100.0
34
 
    r       = int((radius*radius-1)*rank)
35
 
    ranked  = image.filter(ImageFilter.RankFilter(radius,r))
 
39
    rank /= 100.0
 
40
    r = int((radius * radius - 1) * rank)
 
41
    image = imtools.convert_safe_mode(image)
 
42
    ranked = image.filter(ImageFilter.RankFilter(radius, r))
36
43
    if amount < 100:
37
 
        return imtools.blend(image, ranked, amount/100)
 
44
        return imtools.blend(image, ranked, amount / 100)
38
45
    return ranked
39
46
 
40
47
#---Phatch
 
48
 
 
49
 
41
50
class Action(models.Action):
42
51
    """"""
43
52
 
44
 
    label       = _t('Rank')
45
 
    author      = 'Stani'
46
 
    email       = 'spe.stani.be@gmail.com'
47
 
    init        = staticmethod(init)
48
 
    pil         = staticmethod(rnk)
49
 
    version     = '0.1'
50
 
    tags        = [_t('filter')]
51
 
    __doc__     = _t("Copies the rank'th pixel value")
 
53
    label = _t('Rank')
 
54
    author = 'Stani'
 
55
    email = 'spe.stani.be@gmail.com'
 
56
    init = staticmethod(init)
 
57
    pil = staticmethod(rnk)
 
58
    version = '0.1'
 
59
    tags = [_t('filter')]
 
60
    __doc__ = _t("Copies the rank'th pixel value")
52
61
 
53
 
    def interface(self,fields):
 
62
    def interface(self, fields):
54
63
        fields[_t('Radius')] = self.RankSizeField(self.RANK_SIZES[0])
55
 
        fields[_t('Rank')]   = self.SliderField(50,0,100)
56
 
        fields[_t('Amount')] = self.SliderField(100,1,100)
 
64
        fields[_t('Rank')] = self.SliderField(50, 0, 100)
 
65
        fields[_t('Amount')] = self.SliderField(100, 1, 100)
57
66
 
58
67
    icon = \
59
68
'x\xda\x01v\x0c\x89\xf3\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\