A look at the Pixage tool
Image size limit is one of the worst parts when we are uploading some files to any website. There are many free websites that allow you to resize the images for free but we can’t afford to lose our privacy by uploading the images to any websites.
Pixage is a command line image format tool using which we can use to convert image formats, resize images, and other optional pre-processing. It supports all the common formats including PNG, JPEG, and JPG. Pixage provides an easy interface to customize various parameters like resolution, compression, etc.
- Enlarge and reduce image resolution
- Convert image formats
First, you need to import all the basic packages and initialize them
Since this is a CLI tool we need to create a function that will act as arguments while running the script
We are creating a function to change the image format from JPG/JPEG to PNG
Similarly, we are creating multiple functions which will act as arguments while executing the script in the terminal.
- PNG to JPG
2. Reduce the dimensions of the Image
3. Enlarge the dimensions of the Image
4. Help Command
Now you must be wondering what the
options() function will be doing in the previous code blocks.
So, now let’s define the options function:
Finally, let’s define the
The if condition will check whether an argument is passed while executing the script:
Open the terminal and change the location to the folder with the Python file.
Run the following command to see the magic:
pixage.py topng /home/arjun-ms/Documents/Pixage/cat.jpegpixage.py reduce /home/arjun-ms/Documents/Pixage/cat.jpeg 2