0

I would like to finish my script, I tried a lot to solve but being a beginner failed. I have a function imageio which takes image from website and after that, i would like resize all images in 63x88 and put all my images in one pdf.

full_path = os.path.join(filePath1, name + ".png")
if os.path.exists(full_path):
    number = 1
    while True:
        full_path = os.path.join(filePath1, name + str(number) + ".png")
        if not os.path.exists(full_path):
            break
        number += 1
imageio.imwrite(full_path, im_padded.astype(np.uint8))       
os.chmod(full_path, mode=0o777)

thanks for answer

Dani Mesejo
  • 61,499
  • 6
  • 49
  • 76

1 Answers1

0

We (ImageIO) currently don't have a PDF reader/writer. There is a long-standing features request for it, which hasn't been implemented yet because there is currently nobody willing to contribute it.

Regarding the loading of images, we have an example for this in the docs:

import imageio as iio
from pathlib import Path

images = list()
for file in Path("path/to/folder").iterdir():
    im = iio.imread(file)
    images.append(im)

The caveat is that this particular example assumes that you want to read all images in a folder, and that there is only images in said folder. If either of these cases doesn't apply to you, you can easily customize the snippet.

Regarding the resizing of images, you have several options, and I recommend scikit-image's resize function.

To then get all the images into a PDF, you could have a look at matplotlib, which can generate a figure which you can save as a PDF file. The exact steps to do so will depend on the desired layout of your resulting pdf.

FirefoxMetzger
  • 2,880
  • 1
  • 18
  • 32