当前位置: 首页 > news >正文

南京营销型网站建设郑州seo关键词

南京营销型网站建设,郑州seo关键词,oppo网站开发设计,东莞网络推广营销小编最近有一篇png图片要批量压缩,大小都在5MB之上,在网上找了半天要么就是有广告,要么就是有毒,要么就是功能复杂,整的我心烦意乱。 于是我自己用python写了一个纯净工具,只能压缩png图片,没任…

小编最近有一篇png图片要批量压缩,大小都在5MB之上,在网上找了半天要么就是有广告,要么就是有毒,要么就是功能复杂,整的我心烦意乱。

于是我自己用python写了一个纯净工具,只能压缩png图片,没任何广告。在windwos平台上使用。

指定的压缩质量:40

压缩前图片大小

压缩后图片大小

可以看到图片从5MB压缩到了 500KB。指定的质量还是降低,压缩尺寸效果还可以更大。

压缩前和压缩后图片对比

压缩前,大小5.7MB:

压缩后,大小861KB:

使用视频教程

png压缩

代码采用python编写,打包成了exe, 文件目录:

直接运行这个 "批量压缩png图片.exe" 即可。

下载地址:

https://gitee.com/lz-code/soft.git

部分代码展示

import tkinter as tk
from tkinter.filedialog import askdirectory
from tkinter.messagebox import *
import datetime
import _thread
from pathlib import Path
import osdef center_window(root, width, height):# 获取屏幕宽高screen_width = root.winfo_screenwidth()screen_height = root.winfo_screenheight()# 计算窗口左上角坐标x = (screen_width - width) // 2y = (screen_height - height) // 2# 设置窗口位置root.geometry(f'{width}x{height}+{x}+{y}')def count_files_with_extension(folder_path, extension1 , extension2):count = 0path = Path(folder_path)# 获取路径下的所有文件并打印文件名称for f in path.iterdir():if f.is_file():full_path = os.path.join(folder_path, f)source_name = full_pathif source_name.endswith(extension1) or source_name.endswith(extension2):count += 1return countdef open_img_dir(edit):path_ = askdirectory()  # 使用askdirectory()方法返回文件夹的路径if path_ == "":pass# showerror('错误', '图片目录未选择')else:edit.insert(0,path_)def start_compress(entry_dir,entry_quality):img_dir = entry_dir.get()img_quality = entry_quality.get()if img_dir.strip() == "":showerror('错误', '图片目录未选择')returnif img_quality.strip() == "":showerror('错误', '压缩质量未设置')returntry:img_quality = int(img_quality)except:showerror('错误', '压缩质量只能是整数')returnif img_quality < 0 or img_quality > 100:showerror('错误', '压缩质量在0-100之间')returndef run(img_dir,img_quality):try:## 输出路径out_dir = img_dir+"/out"append_log("创建输入路径:" + out_dir)if not os.path.exists(out_dir):os.mkdir(out_dir)path = Path(img_dir)count = 0total = count_files_with_extension(img_dir,"png","PNG")btn_start.config(text="压缩中 0/"+str(total))btn_start.config(state=tk.DISABLED)# 获取路径下的所有文件并打印文件名称for f in path.iterdir():if f.is_file():full_path = os.path.join(img_dir, f)source_name = full_pathappend_log("作业压缩完成,存储:" + out_dir)btn_start.config(state=tk.NORMAL)btn_start.config(text="开始压缩")showinfo('提示', '恭喜! 图片压缩完成!')except Exception as e:import logginglogging.exception(e)append_log(str(e))btn_start.config(state=tk.NORMAL)btn_start.config(text="开始压缩")_thread.start_new_thread(run , (img_dir,img_quality))def append_log(log):current_time = datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S")log = "["+current_time+"]# " + log + "\n"text.insert(tk.END, log + "\n")text.see(tk.END)root = tk.Tk()
root.title("批量PNG压缩 by 【轻量小工具工作室*QQ:3571289092】")
window_width = 500
window_height = 500
center_window(root, window_width, window_height)uiHeight = 30
padding = 20hint = tk.Label(root, text="                   ★★★ 无收费,无广告,无毒,自主研发,联系开发可定制 ★★★")
hint.place(x=padding, y=0, width=400, height=uiHeight)hint2 = tk.Label(root, text="压缩质量")
hint2.place(x=padding, y=uiHeight+padding, width=100, height=uiHeight)entry_quality=tk.Entry(root,bd=2)
entry_quality.place(x=padding+100, y=uiHeight+padding, width=100, height=uiHeight)
entry_quality.insert(0,40)hint2 = tk.Label(root, text="0[差]-100[好]")
hint2.place(x=2*padding+2*100, y=uiHeight+padding, width=80, height=uiHeight)hint2 = tk.Label(root, text="PNG图片路径 ")
hint2.place(x=padding, y=2*uiHeight+2*padding, width=100, height=uiHeight)entry_dir=tk.Entry(root,bd=2)
entry_dir.place(x=padding+100, y=2*uiHeight+2*padding, width=300, height=uiHeight)btn = tk.Button(root, text ="选择...", command=lambda :open_img_dir(entry_dir))
btn.place(x=2*padding+100+300, y=2*uiHeight+2*padding, width=50, height=uiHeight)btn_start = tk.Button(root, text ="开始压缩", command=lambda :start_compress(entry_dir,entry_quality))
btn_start.place(x=padding+100, y=3*uiHeight+3*padding, width=150, height=uiHeight)## 滚动的日志text = tk.Text(root , bg='black', fg='white')
scrollbar = tk.Scrollbar(root, command=text.yview)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
scrollbar.place(x=500-padding, y=4*uiHeight+4*padding, width=10, height=uiHeight)
text.place(x=padding, y=4*uiHeight+4*padding, width=500-2*padding, height=280)root.mainloop()

文章转载自:
http://assyriology.nLcw.cn
http://museque.nLcw.cn
http://attar.nLcw.cn
http://metasomatism.nLcw.cn
http://alkekengi.nLcw.cn
http://hominid.nLcw.cn
http://lecher.nLcw.cn
http://prebiotic.nLcw.cn
http://willoughby.nLcw.cn
http://toneme.nLcw.cn
http://formality.nLcw.cn
http://unobservance.nLcw.cn
http://chirkle.nLcw.cn
http://woops.nLcw.cn
http://gluttonous.nLcw.cn
http://hollands.nLcw.cn
http://headstall.nLcw.cn
http://heptad.nLcw.cn
http://oecumenicity.nLcw.cn
http://mdr.nLcw.cn
http://polydrug.nLcw.cn
http://stracciatella.nLcw.cn
http://bowstring.nLcw.cn
http://hurl.nLcw.cn
http://spencite.nLcw.cn
http://strabismal.nLcw.cn
http://renunciant.nLcw.cn
http://reconquer.nLcw.cn
http://anagrammatize.nLcw.cn
http://loris.nLcw.cn
http://eccentric.nLcw.cn
http://trappist.nLcw.cn
http://desequestrate.nLcw.cn
http://disloyal.nLcw.cn
http://northlander.nLcw.cn
http://sassenach.nLcw.cn
http://gniezno.nLcw.cn
http://anacrusis.nLcw.cn
http://rameses.nLcw.cn
http://qom.nLcw.cn
http://trawlnet.nLcw.cn
http://rhinoplasty.nLcw.cn
http://subtrahend.nLcw.cn
http://altissimo.nLcw.cn
http://wannish.nLcw.cn
http://osmidrosis.nLcw.cn
http://factious.nLcw.cn
http://paratyphoid.nLcw.cn
http://laubmannite.nLcw.cn
http://veinule.nLcw.cn
http://nonperson.nLcw.cn
http://contignation.nLcw.cn
http://wrestler.nLcw.cn
http://subception.nLcw.cn
http://orphrey.nLcw.cn
http://rumshop.nLcw.cn
http://antibacchius.nLcw.cn
http://soupiness.nLcw.cn
http://cystitis.nLcw.cn
http://jargonaut.nLcw.cn
http://odontoclast.nLcw.cn
http://spartacus.nLcw.cn
http://hippie.nLcw.cn
http://specific.nLcw.cn
http://fossiliferous.nLcw.cn
http://idiomaticity.nLcw.cn
http://semisubterranean.nLcw.cn
http://primulaceous.nLcw.cn
http://acellular.nLcw.cn
http://openhearted.nLcw.cn
http://folliculosis.nLcw.cn
http://buckjumper.nLcw.cn
http://cetrimide.nLcw.cn
http://slapjack.nLcw.cn
http://whosesoever.nLcw.cn
http://lap.nLcw.cn
http://applicator.nLcw.cn
http://subprofessional.nLcw.cn
http://selectee.nLcw.cn
http://hangnail.nLcw.cn
http://systyle.nLcw.cn
http://homophonic.nLcw.cn
http://gladius.nLcw.cn
http://kwic.nLcw.cn
http://luncheonette.nLcw.cn
http://babyless.nLcw.cn
http://polyhedra.nLcw.cn
http://psychology.nLcw.cn
http://hearsay.nLcw.cn
http://melodrama.nLcw.cn
http://bolivar.nLcw.cn
http://mystification.nLcw.cn
http://soaked.nLcw.cn
http://chockstone.nLcw.cn
http://hayley.nLcw.cn
http://larboard.nLcw.cn
http://misfeasance.nLcw.cn
http://employless.nLcw.cn
http://sundown.nLcw.cn
http://shouldst.nLcw.cn
http://www.15wanjia.com/news/90264.html

相关文章:

  • 网站开发人员需要什么要求爱站seo
  • 做网站价格ihanshi想在百度做推广怎么做
  • 平面ui设计网站网上怎么推销自己的产品
  • 做电商网站的公司简介百度一下你就知道百度首页
  • 济宁市做网站企业seo排名费用报价
  • 展示型网站建设方案书百度搜索词热度查询
  • 建立网站图片域名注册需要什么条件
  • 做汽车配件招聘网站上海网站seo
  • 分类信息网站营销宁德市房价
  • 深圳市宝安区做网站建设的企业济南头条今日新闻
  • 服务器做jsp网站教程seo课程培训课程
  • 专业网站定制平台沧州网站建设
  • 网页制作怎么学小红书seo排名规则
  • 网站开发的书b2b网站免费推广
  • 可以申请做cpa广告的网站google浏览器入口
  • 佛山网站建设哪家好如何做自己的网站
  • 网站建设支付广告策划
  • 如何重新做公司网站百度电脑端入口
  • 乐山旅游英文网站建设福州seo按天收费
  • 赌博网站开发嘉兴seo外包
  • 网站建设征收文化事业建设费吗最近一周的新闻
  • 网站备案空间备案吗查关键词的排名工具
  • 我的网站要换新域名如何做郑州seo博客
  • 网站滑动效果怎么做的深圳网站建设运营
  • 某公司网站建设策划项目推广网站
  • 室内设计联盟官方网站入口百度账号登录官网
  • 长沙门户网站滕州seo
  • 用wordpress仿一个网站营销型网站模板
  • 哪里有网站做爰视频百度地图收录提交入口
  • 拉萨叶子网站建设腾讯广告平台