LINUX, FOSS AND LIBRARY TECHNOLOGY ENTHUSIAST

Wednesday, January 25, 2023

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

0 comments
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 jpeg irrespective of their format (jpg, png, or gif) and resize all images to 20kb 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 idlink.py 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 zip unzip

5. Make the script executable.

sudo chmod +x idlink.py

6. Run the script.

sudo ./idlink.py

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

Go to Koha > Tools > Upload Patron Images.

Upload the zip file.


Reference:    

No comments:

Post a Comment