Power of PHP: Resizing Images on Command Line

I’m too busy to explain the script now. In short, it scans the current directory for all the JPG images and converts them into smaller image files hardly compromising the quality. I managed to convert a 211 MB album into a 5.8 MB collection with this script. Modify the $dir varible which holds the location of target directory. Make sure the target directory already exists. Also change the $percent inside the resize function to control the output quality.

Thanks to PHP for such powerful image processing. I just ran the following command on my Ubuntu terminal:

I was done! Here’s the source code:

2 Comments Power of PHP: Resizing Images on Command Line

  1. Mayur Shah


    Its very interesting peace of code I had created modules for my project with the help of your above guidance and its help more thank you again for sharing



Leave a Reply

Your email address will not be published. Required fields are marked *