~ubuntu-branches/ubuntu/oneiric/phatch/oneiric

« back to all changes in this revision

Viewing changes to phatch/actions/offset.py

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2008-02-13 23:48:47 UTC
  • Revision ID: james.westby@ubuntu.com-20080213234847-mp6vc4y88a9rz5qz
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Phatch - Photo Batch Processor
 
2
# Copyright (C) 2007-2008 www.stani.be
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation, either version 3 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program.  If not, see http://www.gnu.org/licenses/
 
16
#
 
17
# Phatch recommends SPE (http://pythonide.stani.be) for editing python files.
 
18
 
 
19
# Embedded icon is taken from www.openclipart.org (public domain)
 
20
 
 
21
from core import models
 
22
from core.translation import _t, new
 
23
 
 
24
#---PIL
 
25
def init():
 
26
    global ImageChops
 
27
    import ImageChops
 
28
    
 
29
def offset(image,horizontal_offset,vertical_offset=None):
 
30
    return ImageChops.offset(image, horizontal_offset, vertical_offset)
 
31
 
 
32
#---Phatch
 
33
class Action(models.Action):
 
34
    label       = _t('Offset')
 
35
    author      = 'Stani'
 
36
    email       = 'spe.stani.be@gmail.com'
 
37
    init        = staticmethod(init)
 
38
    pil         = staticmethod(offset)
 
39
    version     = '0.1'
 
40
    tags        = [_t('transform')]
 
41
    __doc__     = _t('Offset by distance and wrap around')
 
42
    
 
43
    def interface(self,fields):
 
44
        fields[_t('Horizontal Offset')] = self.PixelField('50%')
 
45
        fields[_t('Vertical Offset')]   = self.PixelField('50%')
 
46
    
 
47
    def values(self,info):
 
48
        #pixel fields
 
49
        x, y        = info[new('Pil','Size')]
 
50
        return super(Action,self).values(info, 
 
51
            pixel_fields={'Horizontal Offset': x, 'Vertical Offset': y})
 
52
        
 
53
    icon = \
 
54
'x\xda\x01\xf5\x05\n\xfa\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\
 
55
\x00\x000\x08\x06\x00\x00\x00W\x02\xf9\x87\x00\x00\x00\x04sBIT\x08\x08\x08\
 
56
\x08|\x08d\x88\x00\x00\x05\xacIDATh\x81\xed\xd8{\x8cTw\x15\x07\xf0\xcf\xcc\
 
57
\xec<vg\xb6T\x83B\n6\x8a/\xd2&H\x91\xc4\xc4\xd0\xb4$\xb5\xb4j\x1b\xeb\x83\
 
58
\xe0\xa3$\xa2\xa6m\x10\xa9\x94\xd2&>X\x15\x1f`R!\x9a&\xb8\xa9\x8d\x01$\xd2?J\
 
59
\x03\xad\xa6V\xe1\x8f*5\x8a\xa5\xb1T\x04E\xa5\x18\x9a\x96\xa5Ev\xe7\xb53s\
 
60
\xfd\xe3\xde\xbb\\`vvi\xfb\x97\xce79\xd9;w\xe7\x9es\xbe\xe7\x9c\xdf9\xe7\x0e\
 
61
]t\xd1E\x17]t\xd1E\x17\xff\xbfHM\xea[+\\\xa2\xcfZiW\xa1(\xf0\xa2\x96\x9d6\
 
62
\xf8\t\x82Wk\xfc>z{\xf8d\x8a\xebR\xcc\n8\x13\xf0T\xc0\xe0J\x8e\xbd>\x04\x06\
 
63
\xbcY\xda2\x19\xcb\x05f\x82\x16\x9ahZo\x9d{_\x8d\xf3\xf7\xf3\xee\x0c\x8f\xa5\
 
64
\x99\x95J8\xd2B@\xa5\xc5go\xe7\xe7\xaf\x9d\xc0\x06se<-}\x9e\x95\x06\x1a\x9a\
 
65
\xeaf\x1b\xf0\xb7\x8b%\xf0 \x8fg\xf8@\x1a\xe9\xc4\xfd\x96\xb1\xf8\x8c\x06\
 
66
\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
107
\xdfk\x83\n/\xc6\xb5\x1f\x1d\xad\x0bW\xf9\x8b"\xb0\xdei\xeb\xdd\xe3\x94\xb7\
 
108
\x18\xb1\xd2\x88]\x86}\xd4\xf2\x0e\xef\xbd\xf7\x98"=\xb6J\xec\x91\xb6t\xb2\
 
109
\x0e\x94\x99r\xde\x01\xae_\x0c\x81\xc9\xfd\xac2\x11\xee\xb6E\xca\xe5\xf8\xc1\
 
110
dK\x076\xb1 \xc3`\x8a\xe9\xc2\xfd\xf7\x95V\xb8\xdf\xacX\xc1\xde\xd7\xc5\xb7.\
 
111
\xba\xe8\xa2\x8b.\xba\xe8\xa2\x8b\xffa\xfc\x17\x04\xec\x08\xf14\xc1\xbc\xe9\
 
112
\x00\x00\x00\x00IEND\xaeB`\x82\xb8\x05\xf3\x8b'