~ubuntu-branches/ubuntu/quantal/openerp6.1/quantal-proposed

« back to all changes in this revision

Viewing changes to openerp/addons/auction/report/photo_shadow.py

  • Committer: Package Import Robot
  • Author(s): Yolanda Robla
  • Date: 2012-09-20 15:29:00 UTC
  • Revision ID: package-import@ubuntu.com-20120920152900-woyy3yww8z6acmsk
Tags: upstream-6.1-1+dfsg
ImportĀ upstreamĀ versionĀ 6.1-1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#    
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 
6
#
 
7
#    This program is free software: you can redistribute it and/or modify
 
8
#    it under the terms of the GNU Affero General Public License as
 
9
#    published by the Free Software Foundation, either version 3 of the
 
10
#    License, or (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU Affero General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU Affero General Public License
 
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
 
19
#
 
20
##############################################################################
 
21
 
 
22
def convert_catalog(from_file, to_file, size=220) :
 
23
    return __convert(from_file, to_file, size)
 
24
 
 
25
def convert(from_file, to_file):
 
26
    size = 95
 
27
    __convert(from_file, to_file, size=95)
 
28
 
 
29
def __convert(from_file, to_file, size=95):
 
30
    from PIL import Image, ImageDraw, ImageFilter
 
31
    im = Image.open(from_file)
 
32
    if float(im.size[1]/im.size[0])>2:
 
33
        im = im.resize((im.size[0]*size/im.size[1], size))
 
34
    else:
 
35
        im = im.resize((size,im.size[1]*size/im.size[0]))
 
36
    newimg = Image.new('RGB', (im.size[0]+8,im.size[1]+8), (255,255,255) )
 
37
 
 
38
    draw = ImageDraw.Draw(newimg)
 
39
    draw.rectangle((6, im.size[1]-5, im.size[0], im.size[1]+5), fill=(90,90,90))
 
40
    draw.rectangle((im.size[0]-5, 6, im.size[0]+5, im.size[1]), fill=(90,90,90))
 
41
    del draw 
 
42
 
 
43
    newimg = newimg.filter(ImageFilter.BLUR)
 
44
    newimg = newimg.filter(ImageFilter.BLUR)
 
45
    newimg = newimg.filter(ImageFilter.BLUR)
 
46
 
 
47
    newimg.paste(im, (0,0))
 
48
    draw = ImageDraw.Draw(newimg)
 
49
    draw.rectangle((0, 0, im.size[0], im.size[1]), outline=(0,0,0))
 
50
    del draw 
 
51
    to_fp = file(to_file, 'wb')
 
52
    newimg.save(to_fp, "JPEG")
 
53
    to_fp.close()
 
54
    res = newimg.size
 
55
    del im
 
56
    del newimg
 
57
    return res
 
58
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
59