mirror of
https://github.com/LucasVbr/img-to-pdf.git
synced 2026-07-09 15:07:53 +00:00
Create "script" folder
This commit is contained in:
+44
-44
@@ -1,44 +1,44 @@
|
|||||||
"""
|
"""
|
||||||
ToPDF.py , 25/06/2021
|
ToPDF.py , 25/06/2021
|
||||||
no copyright
|
no copyright
|
||||||
author: LucasVBR
|
author: LucasVBR
|
||||||
"""
|
"""
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
import tkinter
|
import tkinter
|
||||||
from tkinter.filedialog import askopenfilenames
|
from tkinter.filedialog import askopenfilenames
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Program that convert Images into PDF
|
Program that convert Images into PDF
|
||||||
The order of Images is by name in alphanumerical
|
The order of Images is by name in alphanumerical
|
||||||
The name of the PDF is the same than the first file selected
|
The name of the PDF is the same than the first file selected
|
||||||
|
|
||||||
If there is 0 files selected, the program stop
|
If there is 0 files selected, the program stop
|
||||||
"""
|
"""
|
||||||
|
|
||||||
root = tkinter.Tk()
|
root = tkinter.Tk()
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# Select files
|
# Select files
|
||||||
files = askopenfilenames(title='Images a convertir en PDF',
|
files = askopenfilenames(title='Images a convertir en PDF',
|
||||||
filetypes=[("Images", "*.jpg *.jpeg *.png"),
|
filetypes=[("Images", "*.jpg *.jpeg *.png"),
|
||||||
("All", "*.*")])
|
("All", "*.*")])
|
||||||
|
|
||||||
if len(files) > 0: # There is files : Convert them
|
if len(files) > 0: # There is files : Convert them
|
||||||
|
|
||||||
imageList = []
|
imageList = []
|
||||||
for image in files:
|
for image in files:
|
||||||
temp = Image.open(rf"{image}")
|
temp = Image.open(rf"{image}")
|
||||||
imageList.append(temp.convert('RGB'))
|
imageList.append(temp.convert('RGB'))
|
||||||
|
|
||||||
|
|
||||||
pdf_file = f"out/{path.splitext(path.basename(files[0]))[0]}.pdf"
|
pdf_file = f"out/{path.splitext(path.basename(files[0]))[0]}.pdf"
|
||||||
|
|
||||||
imageList[0].save(rf"{pdf_file}",
|
imageList[0].save(rf"{pdf_file}",
|
||||||
save_all=True,
|
save_all=True,
|
||||||
append_images=imageList[1:])
|
append_images=imageList[1:])
|
||||||
else: # Stop
|
else: # Stop
|
||||||
break
|
break
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
:: execute.bat, 25/06/2021
|
:: execute.bat, 25/06/2021
|
||||||
:: no copyright
|
:: no copyright
|
||||||
:: author: LucasVBR
|
:: author: LucasVBR
|
||||||
|
|
||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
|
|
||||||
:: Execute script
|
:: Execute script
|
||||||
if exist ./ToPDF.py (
|
if exist ./ToPDF.py (
|
||||||
:: Create folder if it do not exist
|
:: Create folder if it do not exist
|
||||||
if not exist out mkdir out
|
if not exist out mkdir out
|
||||||
|
|
||||||
python ./ToPDF.py
|
python ./ToPDF.py
|
||||||
) else (
|
) else (
|
||||||
echo ToPDF.py doesn't exist
|
echo ToPDF.py doesn't exist
|
||||||
pause
|
pause
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user