-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8323a6a
commit 3e08eee
Showing
2 changed files
with
59 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
""" | ||
ToPDF.py , 25/06/2021 | ||
no copyright | ||
author: LucasVBR | ||
""" | ||
from os import path | ||
|
||
import tkinter | ||
from tkinter.filedialog import askopenfilenames | ||
|
||
from PIL import Image | ||
|
||
""" | ||
Program that convert Images into PDF | ||
The order of Images is by name in alphanumerical | ||
The name of the PDF is the same than the first file selected | ||
If there is 0 files selected, the program stop | ||
""" | ||
|
||
root = tkinter.Tk() | ||
root.withdraw() | ||
|
||
while True: | ||
# Select files | ||
files = askopenfilenames(title='Images a convertir en PDF', | ||
filetypes=[("Images", "*.jpg *.jpeg *.png"), | ||
("All", "*.*")]) | ||
|
||
if len(files) > 0: # There is files : Convert them | ||
|
||
imageList = [] | ||
for image in files: | ||
temp = Image.open(rf"{image}") | ||
imageList.append(temp.convert('RGB')) | ||
|
||
|
||
pdf_file = f"out/{path.splitext(path.basename(files[0]))[0]}.pdf" | ||
|
||
imageList[0].save(rf"{pdf_file}", | ||
save_all=True, | ||
append_images=imageList[1:]) | ||
else: # Stop | ||
break | ||
""" | ||
ToPDF.py , 25/06/2021 | ||
no copyright | ||
author: LucasVBR | ||
""" | ||
from os import path | ||
|
||
import tkinter | ||
from tkinter.filedialog import askopenfilenames | ||
|
||
from PIL import Image | ||
|
||
""" | ||
Program that convert Images into PDF | ||
The order of Images is by name in alphanumerical | ||
The name of the PDF is the same than the first file selected | ||
If there is 0 files selected, the program stop | ||
""" | ||
|
||
root = tkinter.Tk() | ||
root.withdraw() | ||
|
||
while True: | ||
# Select files | ||
files = askopenfilenames(title='Images a convertir en PDF', | ||
filetypes=[("Images", "*.jpg *.jpeg *.png"), | ||
("All", "*.*")]) | ||
|
||
if len(files) > 0: # There is files : Convert them | ||
|
||
imageList = [] | ||
for image in files: | ||
temp = Image.open(rf"{image}") | ||
imageList.append(temp.convert('RGB')) | ||
|
||
|
||
pdf_file = f"out/{path.splitext(path.basename(files[0]))[0]}.pdf" | ||
|
||
imageList[0].save(rf"{pdf_file}", | ||
save_all=True, | ||
append_images=imageList[1:]) | ||
else: # Stop | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
:: execute.bat, 25/06/2021 | ||
:: no copyright | ||
:: author: LucasVBR | ||
|
||
@ECHO OFF | ||
|
||
:: Execute script | ||
if exist ./ToPDF.py ( | ||
:: Create folder if it do not exist | ||
if not exist out mkdir out | ||
|
||
python ./ToPDF.py | ||
) else ( | ||
echo ToPDF.py doesn't exist | ||
pause | ||
:: execute.bat, 25/06/2021 | ||
:: no copyright | ||
:: author: LucasVBR | ||
|
||
@ECHO OFF | ||
|
||
:: Execute script | ||
if exist ./ToPDF.py ( | ||
:: Create folder if it do not exist | ||
if not exist out mkdir out | ||
|
||
python ./ToPDF.py | ||
) else ( | ||
echo ToPDF.py doesn't exist | ||
pause | ||
) |