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

网站开发需要几个人wordpress双按钮设置

网站开发需要几个人,wordpress双按钮设置,网站建设伍金手指下拉2,广西南宁网站建设哪家好最近同事经常找我帮她打印试卷#xff0c;很奇葩的是#xff0c;她的试卷都是*红书上下载的图片#xff0c;一张张打印不好看#xff0c;而且可能打印不完全#xff0c;大小也不协调#xff0c;所以有了这个脚本。 【需要给小孩打印图片格式的试卷时也比较实用】 -----…最近同事经常找我帮她打印试卷很奇葩的是她的试卷都是*红书上下载的图片一张张打印不好看而且可能打印不完全大小也不协调所以有了这个脚本。 【需要给小孩打印图片格式的试卷时也比较实用】 --------------------------------------------------------------------------------------------------------------------------------- 使用方法 方法一直接将脚本放到图片文件夹内并运行脚本 方法二命令行运行 命令行参数 python convert_images_to_pdf.py [图片文件夹路径] [PDF保存路径]  图片文件夹路径可选默认为python脚本所在目录  PDF保存路径可选默认路径为 图片文件夹路径 文件名为图片文件夹名.PDF。需先指定图片文件夹路径后再指定PDF保存路径 --------------------------------------------------------------------------------------------------------------------------------- 命令行示例 假设脚本名为convert_images_to_pdf.py只指定图片目录 python convert_images_to_pdf.py C:\img_folder 同时指定图片目录和pdf路径  python convert_images_to_pdf.py C:\img_folder  D:\result.pdf 代码 # -*- coding: utf-8 -*-import os import subprocess import sysfrom PIL import Image from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvasdef pause_exit():subprocess.run(pause, shellTrue)exit()def get_images(img_folder):遍历目录获取目录下所有的图片img_format (.jpg, .png, .bmp)images []for file_name in os.listdir(img_folder):if file_name.lower().endswith(img_format):images.append(os.path.join(img_folder, file_name))return sorted(images)def get_image_size(img_file, page_width, page_height):设置每个图片的大小with Image.open(img_file) as img:img_width, img_height img.sizeif img_height page_height * 0.95 or img_width page_width * 0.95:height_scale (page_height * 0.95) / img_heightwidth_scale (page_width * 0.95) / img_widthscale min(height_scale, width_scale)img_width * scaleimg_height * scalereturn img_width, img_heightdef create_pdf(pdf_file, images, page_width, page_height):创建 pdf 文件并添加图片c canvas.Canvas(pdf_file, pagesizeletter)total_images len(images)for i, img_path in enumerate(images):img_width, img_height get_image_size(img_path, page_width, page_height)x (page_width - img_width) / 2y (page_height - img_height) / 2c.drawImage(img_path, x, y, img_width, img_height)c.showPage()progress_bar(i 1, total_images)c.save()def create_pdf_from_path(img_folder, pdf_fileNone):遍历给定路径将路径下的图片添加进pdf并将pdf保存在指定路径下images get_images(img_folder)if images:if not pdf_file:pdf_name os.path.basename(img_folder) .pdfpdf_file os.path.join(img_folder, pdf_name)page_width, page_height lettercreate_pdf(pdf_file, images, page_width, page_height)return pdf_fileelse:print(f{img_folder} 下没有图片当前支持的图片格式为 jpg、png 和 bmp)pause_exit()def progress_bar(current, total, bar_length60):进度条filled_length int(bar_length * current // total)bar * filled_length - * (bar_length - filled_length)percent current / total * 100sys.stdout.write(f\r处理进度|{bar}| {percent:.2f}%)sys.stdout.flush()if __name__ __main__:subprocess.run(title 目录内图片转PDF, shellTrue)try:(*rest,) sys.argv[1:]if not rest:img_folder os.getcwd() # 使用当前文件夹作为 img_folderpdf_file Noneelse:img_folder, *pdf_file restpdf_file pdf_file[0] if pdf_file else Noneexcept ValueError:print(请提供图片文件夹路径作为参数)pause_exit()if not os.path.exists(img_folder):print(f{img_folder} 路径不存在)pause_exit()elif not os.path.isdir(img_folder):print(f{img_folder} 不是一个文件夹)pause_exit()else:pdf_file create_pdf_from_path(img_folder, pdf_file)if pdf_file:subprocess.run([explorer, pdf_file])else:pause_exit()
http://www.dnsts.com.cn/news/275365.html

相关文章:

  • 阳江营销型网站建设宁波建设局网站
  • 建网站需要什么资料中国互联网协会会员单位
  • 网站开发主要学什么沃噻网站建设流程
  • 深圳定制网站天津企业网站建设哪家好
  • 医院做网站备案都需要什么做任务换流量的网站
  • 潍坊网站seo如何建一个网站教程
  • 婚介所网站开发费用公司注册资金最少是多少
  • 企业网站建设该怎么描述wordpress 3.9 中文
  • go语言可以做网站吗seo综合查询平台官网
  • 用wix做网站需要备案吗中国最好的网站制作
  • 芜湖市建设工程网站维护公告大兴网站开发网站建设
  • 一个返利网站建设流程如何进行网络销售
  • 清丰网站建设费用互联网精准营销
  • 网站伪静态怎么做专业网站建设服务包括
  • 备案时网站服务内容婚庆网站开发背景
  • 自己做的网站怎么发布到网上开放平台作用发挥明显
  • 网站地图提交给百度贪玩传奇手游官方网站
  • 做网站 所需资源南通市交通建设处网站
  • 苏州艺术家网站建设超简洁WordPress
  • php做用户登录网站邵阳建设银行网站是多少钱
  • 网站建设管理及维护wordpress哪个模板好用吗
  • 网站开发的现状全国做网站的
  • 摄影网站网页设计seo主要做什么工作
  • 网站建设的难点在哪里厦门模板建站哪家好
  • wordpress 网站统计wordpress 删掉
  • 温州做网站定制中国淮南网
  • 合肥企业建网站wordpress自动添加关键词和描述
  • 权威数据统计网站2345网址导航下载
  • 做二手网站好的名字网站开发毕设ppt
  • 株洲网站排名优化价格网站的百度快照如何做