ADD hig_class file via upload

main
pl5uwmvih 5 months ago
parent 58d6cf2e85
commit 910dd87e04

@ -0,0 +1,90 @@
from PIL import Image as Im
import tkinter as tk
from extra import wlw
from tkinter.filedialog import askopenfilename
import tkinter.messagebox
import tkinter.ttk
import tkinter.messagebox
from PIL import ImageDraw
from PIL import ImageFont
from PIL import ImageEnhance
class picture(object):
"""description of class"""
# 打开图像调用
def open_pic(self, address):
self.pic_get = Im.open(address).convert('RGBA')
wid, hei = self.pic_get.size
if wid > 600 or hei > 400:
if tk.messagebox.askokcancel('提示', '图片可能过大,是否压缩?'):
needShow_pic = self.openResize()
return needShow_pic
return self.pic_get
else:
return self.pic_get
# 打开图像时的图像压缩展示
def openResize(self):
w, h = self.pic_get.size
w_hope = 500
h_hope = 300
f1 = 1.0 * w_hope / w
f2 = 1.0 * h_hope / h
factor = min([f1, f2])
width = int(w * factor)
height = int(h * factor)
pic_show = self.pic_get.resize((width, height))
return pic_show
# 截图处理
def Cutpic(self, pic_preCut, p1, p2, p3, p4):
cropped_pic = pic_preCut.crop((p1, p2, p3, p4)) # 截图
return cropped_pic
# 尺寸大小变化
def changeResize(self, pic_reshow, newWidth, newHeight):
reesizeNew_pic = pic_reshow.resize((newWidth, newHeight)) # 修改尺寸
# print('3')
return reesizeNew_pic
# 镜像左右
def MirrorPic_leftOrright(self, pic_mir_lr):
Mirror_lrFinish = pic_mir_lr.transpose(Im.FLIP_LEFT_RIGHT) # 镜像左右
return Mirror_lrFinish
# 镜像上下
def MirrorPic_topOrbuttom(self, pic_mir_tp):
Mirror_tbFinish = pic_mir_tp.transpose(Im.FLIP_TOP_BOTTOM) # 镜像上下
return Mirror_tbFinish
# 旋转
def rotatePic(self, pic_prerotate, rodegreee):
rotateNew_pic = pic_prerotate.rotate(rodegreee, expand=True)
return rotateNew_pic
# 亮度
def brightPic(self, pic_prebright, n):
pic_brighted = ImageEnhance.Brightness(pic_prebright).enhance(n) # 亮度
return pic_brighted
# 色彩度
def colornPic(self, pic_preColor, n):
pic_colored = ImageEnhance.Color(pic_preColor).enhance(n) # 色彩度
return pic_colored
# 对比度
def constractPic(self, pic_preCon, n):
enh_con = ImageEnhance.Contrast(pic_preCon)
contrast = n
pic_contrasted = enh_con.enhance(contrast) # 对比度
return pic_contrasted
# 锐度调整
def sharpPic(self, pic_preSharp, n):
pic_sharped = ImageEnhance.Sharpness(pic_preSharp).enhance(n)
return pic_sharped
Loading…
Cancel
Save