示例#1
0
def shadowImage(image, color='#3896f8', factor=0.3):
    if not hasattr(image, '_pil_image'):
        return None
    im = image._pil_image
    if Image.VERSION >= '1.1.7':
        # use an alpha image
        sh = Image.new('RGBA', im.size, color)
        sh.putalpha(100)
        out = Image.composite(sh, im, im)
        return PIL_Image(image=out)
    sh = Image.new('RGBA', im.size, color)
    tmp = Image.blend(im, sh, factor)
    out = Image.composite(tmp, im, im)
    return PIL_Image(image=out)
示例#2
0
def shadowImage(image, color='#3896f8', factor=0.3):
    if not hasattr(image, '_pil_image'):
        return None
    im = image._pil_image
    if Image.VERSION >= '1.1.7':
        # use an alpha image
        sh = Image.new('RGBA', im.size, color)
        sh.putalpha(100)
        out = Image.composite(sh, im, im)
        return PIL_Image(image=out)
    sh = Image.new('RGBA', im.size, color)
    tmp = Image.blend(im, sh, factor)
    out = Image.composite(tmp, im, im)
    return PIL_Image(image=out)
示例#3
0
def shadowImage(image, color='#3896f8', factor=0.3):
    if not hasattr(image, '_pil_image'):
        return None
    im = image._pil_image
    # use an alpha image
    sh = Image.new('RGBA', im.size, color)
    sh.putalpha(100)
    out = Image.composite(sh, im, im)
    return PIL_Image(image=out)
示例#4
0
文件: tkutil.py 项目: shlomif/PySolFC
def shadowImage(image, color='#3896f8', factor=0.3):
    if not hasattr(image, '_pil_image'):
        return None
    im = image._pil_image
    # use an alpha image
    sh = Image.new('RGBA', im.size, color)
    sh.putalpha(100)
    out = Image.composite(sh, im, im)
    return PIL_Image(image=out)
示例#5
0
def markImage(image):
    assert Image
    if 1:                               # shadow
        color, factor = '#6ae400', 0.3
        sh = Image.new('RGBA', image.size, color)
        tmp = Image.blend(image, sh, factor)
    else:                               # negate
        tmp = ImageOps.invert(image.convert('RGB'))
    out = Image.composite(tmp, image, image)
    return out
示例#6
0
def markImage(image):
    assert Image
    if 1:  # shadow
        color, factor = '#6ae400', 0.3
        sh = Image.new('RGBA', image.size, color)
        tmp = Image.blend(image, sh, factor)
    else:  # negate
        tmp = ImageOps.invert(image.convert('RGB'))
    out = Image.composite(tmp, image, image)
    return out
示例#7
0
 def _createDisabledButtonImage(self, tkim):
     # grayscale and light-up image
     if not tkim:
         return None
     im = tkim._pil_image
     dis_im = ImageOps.grayscale(im)
     ##color = '#ffffff'
     ##factor = 0.6
     color = '#dedede'
     factor = 0.7
     sh = Image.new(dis_im.mode, dis_im.size, color)
     tmp = Image.blend(dis_im, sh, factor)
     dis_im = Image.composite(tmp, im, im)
     dis_tkim = ImageTk.PhotoImage(image=dis_im)
     return dis_tkim
示例#8
0
 def _createDisabledButtonImage(self, tkim):
     # grayscale and light-up image
     if not tkim:
         return None
     im = tkim._pil_image
     dis_im = ImageOps.grayscale(im)
     # color = '#ffffff'
     # factor = 0.6
     color = '#dedede'
     factor = 0.7
     sh = Image.new(dis_im.mode, dis_im.size, color)
     tmp = Image.blend(dis_im, sh, factor)
     dis_im = Image.composite(tmp, im, im)
     dis_tkim = ImageTk.PhotoImage(image=dis_im)
     return dis_tkim
示例#9
0
文件: tkutil.py 项目: jimsize/PySolFC
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
示例#10
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