Wednesday, January 25, 2023

Python script to convert, resize, and compress images in bulk

Here is the modified version of the Python script created by Mr. A.J. Tomson, Librarian, Devagiri College, Kozhikode. It was helpful for creating an idlink.txt and compressing images. But this modified script will help you convert images into jpg irrespective of their format (jpeg, png, or gif) and resize all images to 50% width and height without losing their actual aspect ratio and create a zip file.  

NB: The script has been tested with Debian 11 and Ubuntu 20.04 LTS.

Using the script

1. Arrange your photos in a folder. Check that the photo name matches the patron's card number.

2. Go to the following link and click on the "Download" button.

3. Place the script in the photos directory.

4. Open a terminal, enter inside the photo folder, and apply the following commands: This script uses python3, so install it.

sudo apt update
sudo apt -y install python3

5. Make the script executable.

sudo chmod +x

6. Run the script.

sudo ./

7. After the process, you can see a zip file where all your photos have been compressed.

Go to Koha > Tools > Upload Patron Images.

Upload the zip file.


No comments:

Post a Comment