Update usr/lib/xshot/xshot.py
parent
59e6e16a94
commit
8337bece17
|
@ -1,7 +1,26 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os, sys, site, sysconfig
|
||||||
|
|
||||||
import gi, sys, os, cairo, math
|
sandbox = sys.path[-1]
|
||||||
|
|
||||||
|
# 获取标准库路径
|
||||||
|
stdlib = sysconfig.get_paths()['stdlib'].replace(sandbox, '/usr')
|
||||||
|
|
||||||
|
# 获取系统库路径
|
||||||
|
site_packages = site.getsitepackages()
|
||||||
|
|
||||||
|
|
||||||
|
if stdlib not in sys.path:
|
||||||
|
sys.path.append(stdlib)
|
||||||
|
|
||||||
|
for path in site_packages:
|
||||||
|
path = path.replace(sandbox, '/usr')
|
||||||
|
if path not in sys.path:
|
||||||
|
sys.path.append(path)
|
||||||
|
|
||||||
|
|
||||||
|
import gi, cairo, math
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service, dbus.mainloop.glib
|
import dbus.service, dbus.mainloop.glib
|
||||||
|
|
||||||
|
@ -13,6 +32,7 @@ from PIL import Image, ImageFilter, ImageChops
|
||||||
app_id = 'fun.wkit.xshot'
|
app_id = 'fun.wkit.xshot'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pixbuf_to_pil(pixbuf):
|
def pixbuf_to_pil(pixbuf):
|
||||||
data = pixbuf.get_pixels()
|
data = pixbuf.get_pixels()
|
||||||
w = pixbuf.get_width()
|
w = pixbuf.get_width()
|
||||||
|
@ -66,7 +86,7 @@ def set_radius(pixbuf, radius = 4):
|
||||||
|
|
||||||
|
|
||||||
def add_shadow(img):
|
def add_shadow(img):
|
||||||
# 加载图片并确认该图片为RGBA模式,保证透明度
|
# 加载图片并确认该图片为RGBA模式, 保证透明度
|
||||||
img = set_radius(img)
|
img = set_radius(img)
|
||||||
img = pixbuf_to_pil(img).convert('RGBA')
|
img = pixbuf_to_pil(img).convert('RGBA')
|
||||||
w,h = img.size
|
w,h = img.size
|
||||||
|
@ -77,8 +97,8 @@ def add_shadow(img):
|
||||||
shadow = Image.new('RGBA', img.size, (80,80,80,223))
|
shadow = Image.new('RGBA', img.size, (80,80,80,223))
|
||||||
shadow = pixbuf_to_pil(set_radius(pil_to_pixbuf(shadow)))
|
shadow = pixbuf_to_pil(set_radius(pil_to_pixbuf(shadow)))
|
||||||
|
|
||||||
#new_img = Image.new('RGBA', (w,h), (0,0,0,0))
|
new_img = Image.new('RGBA', (w,h), (0,0,0,0))
|
||||||
new_img = Image.new('RGBA', (w,h), (255,255,255,255))
|
#new_img = Image.new('RGBA', (w,h), (255,255,255,255))
|
||||||
new_img.paste(shadow, (32, 32), shadow)
|
new_img.paste(shadow, (32, 32), shadow)
|
||||||
|
|
||||||
new_img = new_img.filter(ImageFilter.GaussianBlur(radius = 12))
|
new_img = new_img.filter(ImageFilter.GaussianBlur(radius = 12))
|
||||||
|
@ -121,6 +141,9 @@ class Application(Gtk.Application):
|
||||||
|
|
||||||
self.copy(image)
|
self.copy(image)
|
||||||
|
|
||||||
|
print('截图成功...')
|
||||||
|
|
||||||
|
|
||||||
class ApplicationService(dbus.service.Object):
|
class ApplicationService(dbus.service.Object):
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
Loading…
Reference in New Issue