Skip to content

rohit2701singh/resize-images

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Image Compression Script

This Python script compresses images in a specified folder and saves the compressed versions in an output folder. It supports .jpg, .jpeg, and .png files. PNG images are converted to JPEG to save more space.

Features

  • Compress .jpg, .jpeg, and .png images.
  • Convert PNG images to JPEG for better compression.
  • Preserve original filenames in the output folder.
  • Customizable image quality (default is 90%).
  • Automatically creates the output folder if it doesn’t exist.
  • Displays progress in the console with image numbers and paths.
  • Handles exceptions gracefully for invalid or corrupted files.

Requirements

Install Pillow using pip if not already installed: pip install Pillow

Usage

  1. Clone or download the script.
  2. Set the input and output folder paths:
input_folder_path = "D:/file path"
output_folder_path = "C:/final path"
  1. Call the function with optional quality parameter (default is 90):
compress_images(input_folder=input_folder_path, output_folder=output_folder_path, quality=90)
  1. Run the script:
python compress_images.py

The compressed images will appear in the specified output folder.

About

Python script for bulk image compression that reduces file size while maintaining quality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages