Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 284617 Details for
Bug 295242
Xmind ebuild request
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
thumbnailer
xmind-thumbnailer (text/plain), 2.48 KB, created by
Heui-mun Park
on 2011-08-25 12:12:49 UTC
(
hide
)
Description:
thumbnailer
Filename:
MIME Type:
Creator:
Heui-mun Park
Created:
2011-08-25 12:12:49 UTC
Size:
2.48 KB
patch
obsolete
>#!/usr/bin/env python > >import gnomevfs >import os >import sys >import zipfile >from PIL import Image, ImageEnhance > ># Alter these varibles to change thumbnail look >ICON_PATH = "/usr/share/icons/hicolor/32x32/apps/xmind.png" # Change this path to alter icons >ICON_OPACITY = 0.6 #Opacity of the icon (between 0.0 and 1.0) >THUMBNAIL_BACKGROUND_COLOR = "white" # Color of the background > >in_file_path = gnomevfs.get_local_path_from_uri(sys.argv[1]) >out_file_path = sys.argv[2] >path_without_thumbs = os.getenv("HOME")+"/Templates" > >def get_icon(thumbnail_size): > #Load icon > icon = Image.open(ICON_PATH).convert("RGBA") > #Set it's opacity > icon = set_icon_opacity(icon,ICON_OPACITY) > #And set it's position in thumbnail > icon_posx=thumbnail_size[0]-icon.size[0] > icon_posy=thumbnail_size[1]-icon.size[1] > icon_width=thumbnail_size[0] > icon_height=thumbnail_size[1] > return {"image":icon,"position":(icon_posx,icon_posy,icon_width,icon_height)} > >def get_basic_thumbnail(): > #Find out if the file is not in Templates directory > if in_file_path.find(path_without_thumbs)!=0: > try: > #Extract thumbnail from Xmind file and save it > zip=zipfile.ZipFile(in_file_path,mode="r") > picture=zip.read("Thumbnails/thumbnail.jpg") > zip.close() > thumbnail=open(out_file_path,"w") > thumbnail.write(picture) > thumbnail.write("/n") > thumbnail.close() > #Open saved thumbnail > image=Image.open(out_file_path).convert("RGBA") > if image.size[0]>200: > image = image.resize((200,image.size[1]*200/image.size[0])) > if image.size[1]>200: > image = image.resize((image.size[0]*200/image.size[1],200)) > return {"suceeded":True,"image":image,"size":(image.size[0],image.size[1])} > > except: > return {"suceeded":False} > else: > return {"suceeded":False} > ># Nicked from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879 >def set_icon_opacity(icon,opacity): > #Returns an image with reduced opacity. > assert opacity >= 0 and opacity <= 1 > if icon.mode != 'RGBA': > icon = icon.convert('RGBA') > else: > icon = icon.copy() > alpha = icon.split()[3] > alpha = ImageEnhance.Brightness(alpha).enhance(opacity) > icon.putalpha(alpha) > return icon > >thumbnail=get_basic_thumbnail() >if thumbnail["suceeded"]: > background=Image.new("RGB", thumbnail["size"], THUMBNAIL_BACKGROUND_COLOR) > icon=get_icon(thumbnail["size"]) > thumbnail=thumbnail["image"] > # Add thumbnail > background.paste(thumbnail, None, thumbnail) > # Add icon > background.paste(icon["image"],icon["position"],icon["image"]) > # Save thumbnail > background.save(out_file_path,"PNG")
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 295242
:
234237
|
254861
|
254863
|
254865
|
254867
|
260586
|
284561
|
284563
|
284565
|
284567
|
284569
|
284613
|
284615
|
284617
|
284619
|
284621
|
284623
|
284625
|
327470