Python PDF转JPG图片小工具
1.简介
将单个pdf装换成jpg格式图片
Tip:
1、软件窗口默认最前端,不支持调整窗口大小;
2、可通过按钮选择PDF文件,也可以直接拖拽文件到窗口;
3、转换质量有5个档位,(0.25,0.5,原分辨率,2倍,4倍),默认为原分辨率;
4、转换后的文件路径与导入文件的路径一致;
5、单页文件直接生成JPG图片,多页文件是生成文件夹;
6、不支持批量转换,不支持文件夹,只能单个文件转换结束再选下一个;
2.运行效果:
3.相关源码:
#coding:utf-8
import tkinter as tk
from tkinter import Label
from tkinter import Entry
from tkinter import filedialog
from tkinter.font import Font
import os
import fitz
from tkinterdnd2 import DND_FILES,TkinterDnD
def center_window(root, width, height): #创建窗口居中
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = int((screen_width - width) / 2)
y = int((screen_height - height) / 2)
root.geometry(f"{
width}x{
height}+{
x}+{
y}")
def open_file(): #浏览文件按钮代码
filetypes = (('pdf files', '*.pdf'),('All files', '*.*'))
file = filedialog.askopenfilename(title='选择PDF文件',initialdir=os.getcwd(),filetypes=filetypes)
pathname.delete(0, tk.END)
pathname_2.delete(0, tk.END)
if str.upper(file<