Exemplo n.º 1
0
 def __init__(self, file=None, image=None, pil_image_orig=None):
     if file:
         image = Image.open(file).convert('RGBA')
     ImageTk.PhotoImage.__init__(self, image)
     self._pil_image = image
     if pil_image_orig:
         self._pil_image_orig = pil_image_orig
     else:
         self._pil_image_orig = image
Exemplo n.º 2
0
 def __init__(self, file=None, image=None, pil_image_orig=None):
     if file:
         image = Image.open(file).convert('RGBA')
     ImageTk.PhotoImage.__init__(self, image)
     self._pil_image = image
     if pil_image_orig:
         self._pil_image_orig = pil_image_orig
     else:
         self._pil_image_orig = image
Exemplo n.º 3
0
 def _loadImage(self, name):
     file = os.path.join(self.dir, name)
     image = None
     for ext in IMAGE_EXTENSIONS:
         file = os.path.join(self.dir, name + ext)
         if os.path.isfile(file):
             if Image:
                 image = ImageTk.PhotoImage(Image.open(file))
             else:
                 image = tkinter.PhotoImage(file=file)
             break
     return image
Exemplo n.º 4
0
 def _loadImage(self, name):
     file = os.path.join(self.dir, name)
     image = None
     for ext in IMAGE_EXTENSIONS:
         file = os.path.join(self.dir, name+ext)
         if os.path.isfile(file):
             if Image:
                 image = ImageTk.PhotoImage(Image.open(file))
             else:
                 image = tkinter.PhotoImage(file=file)
             break
     return image
Exemplo n.º 5
0
def _createBottomImage(image, color='white', backfile=None):
    th = 1                              # thickness
    sh = Image.new('RGBA', image.size, color)
    out = Image.composite(sh, image, image)
    w, h = image.size
    size = (w-th*2, h-th*2)
    tmp = Image.new('RGBA', size, color)
    tmp.putalpha(60)
    mask = out.resize(size, Image.ANTIALIAS)
    out.paste(tmp, (th, th), mask)
    if backfile:
        back = Image.open(backfile).convert('RGBA')
        w0, h0 = back.size
        w1, h1 = w, h
        a = min(float(w1)/w0, float(h1)/h0)
        a = a*0.9
        w0, h0 = int(w0*a), int(h0*a)
        back = back.resize((w0, h0), Image.ANTIALIAS)
        x, y = (w1 - w0) // 2, (h1 - h0) // 2
        out.paste(back, (x, y), back)
    return out
Exemplo n.º 6
0
def _createBottomImage(image, color='white', backfile=None):
    th = 1  # thickness
    sh = Image.new('RGBA', image.size, color)
    out = Image.composite(sh, image, image)
    w, h = image.size
    size = (w - th * 2, h - th * 2)
    tmp = Image.new('RGBA', size, color)
    tmp.putalpha(60)
    mask = out.resize(size, Image.ANTIALIAS)
    out.paste(tmp, (th, th), mask)
    if backfile:
        back = Image.open(backfile).convert('RGBA')
        w0, h0 = back.size
        w1, h1 = w, h
        a = min(float(w1) / w0, float(h1) / h0)
        a = a * 0.9
        w0, h0 = int(w0 * a), int(h0 * a)
        back = back.resize((w0, h0), Image.ANTIALIAS)
        x, y = (w1 - w0) // 2, (h1 - h0) // 2
        out.paste(back, (x, y), back)
    return out
Exemplo n.º 7
0
        def __init__(self, file=None, image=None, pil_image_orig=None):

            if file:
                image = Image.open(file).convert('RGBA')

                basename = os.path.basename(file)
                file_name = os.path.splitext(basename)[0]

                findsum = findfile(file_name)

                if findsum != -3:  # -1 for every check
                    image = masking(image)

                    image.filename = file_name

            ImageTk.PhotoImage.__init__(self, image)
            self._pil_image = image
            if pil_image_orig:
                self._pil_image_orig = pil_image_orig
            else:
                self._pil_image_orig = image
Exemplo n.º 8
0
 def setTile(self, image, stretch=0, save_aspect=0):
     # print 'setTile:', image, stretch
     if image:
         if Image:
             try:
                 self._bg_img = Image.open(image)
             except:
                 return 0
         else:
             try:
                 self._bg_img = loadImage(file=image, dither=1)
             except:
                 return 0
         self._stretch_bg_image = stretch
         self._save_aspect_bg_image = save_aspect
         self.setBackgroundImage()
     else:
         for id in self.__tiles:
             self.delete(id)
         self.__tiles = []
         self._bg_img = None
     return 1
Exemplo n.º 9
0
 def setTile(self, image, stretch=0, save_aspect=0):
     ##print 'setTile:', image, stretch
     if image:
         if Image:
             try:
                 self._bg_img = Image.open(image)
             except:
                 return 0
         else:
             try:
                 self._bg_img = loadImage(file=image, dither=1)
             except:
                 return 0
         self._stretch_bg_image = stretch
         self._save_aspect_bg_image = save_aspect
         self.setBackgroundImage()
     else:
         for id in self.__tiles:
             self.delete(id)
         self.__tiles = []
         self._bg_img = None
     return 1
Exemplo n.º 10
0
 def __init__(self, file=None, image=None):
     if file:
         image = Image.open(file).convert('RGBA')
     ImageTk.PhotoImage.__init__(self, image)
     self._pil_image = image