~ubuntu-branches/debian/jessie/phatch/jessie

« back to all changes in this revision

Viewing changes to phatch/actions/colorize.py

  • Committer: Bazaar Package Importer
  • Author(s): Stani M
  • Date: 2009-10-01 05:36:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20091001053609-wvy9yu0u3i6fuv4t
Tags: 0.2.2-1
* Upstream bugfix release (Closes LP: #236548, #436595, #437161, 
 #437376, #437852, #439108, #439359, #440273, #440956)
* debian/control: Dropped dependency python-wxgtk2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
12
# GNU General Public License for more details.
13
 
 
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program.  If not, see http://www.gnu.org/licenses/
16
16
#
23
23
 
24
24
#---PIL
25
25
def init():
26
 
    global Image, ImageOps
 
26
    global Image, ImageOps, imtools
27
27
    import Image, ImageOps
28
 
    
 
28
    from lib import imtools
 
29
 
29
30
def colorize(image,black,white,amount=100):
30
31
    """Apply a filter
31
32
    - amount: 0-1"""
38
39
        colorized  = colorized.convert('RGBA')
39
40
        colorized.putalpha(image.split()[-1])
40
41
    if amount < 100:
41
 
        return Image.blend(image, colorized, amount/100.0)
 
42
        return imtools.blend(image, colorized, amount/100.0)
42
43
    return colorized
43
44
 
44
45
#---Phatch
51
52
    version     = '0.1'
52
53
    tags        = [_t('color')]
53
54
    __doc__     = _t('Colorize grayscale image')
54
 
    
 
55
 
55
56
    def interface(self,fields):
56
57
        fields[_t('Black')]  = self.ColorField('#735710')
57
58
        fields[_t('White')]  = self.ColorField('#FFFFFF')