enhancement: multiple imgs to pdf
|
@ -1,9 +1,9 @@
|
|||
This script consist of python code which converts PNG to PDF.
|
||||
This script consist of python code which converts several PNG/JPG images to PDF.
|
||||
|
||||
It has a PNG image to use as example. For different image just write url of different image which you want to use/ replace "image.png" with total url of the image file.
|
||||
It has several PNG/JPG images to use as examples. For different image just write url of different image which you want to use. If you want to increase or reduce the number of images you want to convert just add/subtract more lines for opening and converting, and add them to the list.
|
||||
|
||||
Write the location of the PDF to be saved at/ replace 'document.pdf' with the total url and name of pdf along with pdf extension.
|
||||
|
||||
I have used flake8 linting on this as well.
|
||||
|
||||
Dependency: Download python and write "pip install Pillow" in cmd.
|
||||
Dependency: Download python and write "pip install Pillow" in cmd.
|
BIN
scripts/PNG_To_PDF/image1.jpg
Normal file
After Width: | Height: | Size: 182 KiB |
BIN
scripts/PNG_To_PDF/image2.jpg
Normal file
After Width: | Height: | Size: 117 KiB |
BIN
scripts/PNG_To_PDF/image3.jpeg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
scripts/PNG_To_PDF/image4.jpg
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
scripts/PNG_To_PDF/image5.png
Normal file
After Width: | Height: | Size: 159 KiB |
BIN
scripts/PNG_To_PDF/image6.png
Normal file
After Width: | Height: | Size: 2.6 MiB |
Before Width: | Height: | Size: 19 KiB |
19
scripts/PNG_To_PDF/multipleIMGtoPDF.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from PIL import Image
|
||||
|
||||
img_1 = Image.open(r'image1.jpg')
|
||||
img_2 = Image.open(r'image2.jpg')
|
||||
img_3 = Image.open(r'image3.jpeg')
|
||||
img_4 = Image.open(r'image4.jpg')
|
||||
img_5 = Image.open(r'image5.png')
|
||||
img_6 = Image.open(r'image6.png')
|
||||
|
||||
im_1 = img_1.convert('RGB')
|
||||
im_2 = img_2.convert('RGB')
|
||||
im_3 = img_3.convert('RGB')
|
||||
im_4 = img_4.convert('RGB')
|
||||
im_5 = img_5.convert('RGB')
|
||||
im_6 = img_6.convert('RGB')
|
||||
|
||||
imlist = [im_2, im_3, im_4,im_5,im_6]
|
||||
|
||||
im_1.save(r'listimg.pdf', save_all=True, append_images=imlist)
|
|
@ -1,5 +0,0 @@
|
|||
from PIL import Image
|
||||
|
||||
image1 = Image.open(r'png-to-pdf.png')
|
||||
impdf = image1.convert('RGB')
|
||||
impdf.save(r'png-to-pdf.pdf') # noqa
|