enhancement: multiple imgs to pdf

This commit is contained in:
artemis-i-guess 2022-10-03 00:15:36 +05:30
parent 24c9bc1bb4
commit c72054125b
10 changed files with 22 additions and 8 deletions

View File

@ -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. 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. 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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View 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)

View File

@ -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