DEV Community

Cover image for Pixxia - Compress your Images in Optimal Quality for FREE
Dhruv Panchal
Dhruv Panchal

Posted on

Pixxia - Compress your Images in Optimal Quality for FREE

Introduction:

The above script uses lossy compression methods to reduce the document size of your JPG/PNG files. This is achieved by rounding up the (R,G,B) values from each pixel of it's unit digit in your image, therefore lesser number of bytes are required to store the information. Sometimes, there are major changes in the bytes stored well as sometimes there are minor changes so it depends entirely on the pixels of the image.

GitHub logo dhhruv / Pixxia

๐Ÿ–ผ Pixxia uses lossy compression methods to reduce the document size of your JPG/PNG files.

Image Comparison:

Image 1:

Image 2:

For Images >= 6 MB you may see a great compression ratio as compared to the images which are smaller than that.

Download Pixxia.exe for Windows

Setup (Windows):

  1. Install Python
  2. Clone this repository
git clone https://github.com/dhhruv/Pixxia.git
Enter fullscreen mode Exit fullscreen mode
  1. Install, create and activate virtual environment. For instance we create a virtual environment named 'venv'.
pip install virtualenv
python -m virtualenv venv
venv\Scripts\activate.bat
Enter fullscreen mode Exit fullscreen mode
  1. Install dependencies
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Download Pixxia.exe for Windows

How To Use !

  1. Click SELECT INPUT FOLDER Button to select the INPUT FOLDER which contains all the Images to be Compressed/Optimized.
  2. Click SELECT OUTPUT FOLDER Button to select the OUTPUT FOLDER which will contain all the the Compressed/Optimized Images.
  3. Hit the COMPRESS Button and the INPUT FOLDER containing Supported Image Formats will be Compressed and saved in the OUTPUT FOLDER.
  4. Click CLEAR Button to reset the input fields and status bar. (If needed)

NOTE: Recommended to keep INPUT and OUTPUT Folder different for your ease to differentiate between Optimized and Unoptimized Images.

Important Note:

  • This Script goes through each pixel of every supported image in the INPUT folder so it'll take more time than usual to process the Image.
  • This Script is just a Prototype so results may be unexpected.
  • The Authors will not be responsible for any kind of loss of data so it is essential to have a Backup of Original Data placed in the Input Folder. Read the LICENSE for more information.

So, stay tuned for further updates on GitHub:

GitHub logo dhhruv / Pixxia

๐Ÿ–ผ Pixxia uses lossy compression methods to reduce the document size of your JPG/PNG files.

Download Pixxia.exe for Windows

Image Credits:

Top comments (8)

Collapse
 
iamkarshe profile image
Utkarsh Kumar Raut

Nice, we somehow use the same PIL/Pillow at our eCom cronjob for compression.

Magic starts at settings.py line number 49.

github.com/dhhruv/Pixxia/blob/6d9e...

Collapse
 
dhhruv profile image
Dhruv Panchal

Yeah @iamkarshe that's right, that's where the magic starts. And it's interesting to hear that it has been implemented somewhere else. If you've worked in this domain then is there anything you can suggest to make this better ?? It'd help.

Collapse
 
iamkarshe profile image
Utkarsh Kumar Raut

I will share my use case see if any point you can pick up.

  1. We have Python script which mostly runs via cron โ€” it takes original media ref. from database.
  2. Make three versions of original images, <image>_low.jpg, <image>_sd.jpg & <image>_hd.jpg using various parameters in PIL optimize &quality factor. Also we reduce width & height for creating low-resolution images.
  3. Later, we do add some copyright text (this is client-dependent feature).
  4. Send images again to S3 where it is serving to app/web via Cloudfront.
  5. Lately we exposed API via Flask for client blogs & eCom where on-the fly media are now being compressed & stored.

Update

  1. We are now started to use .webp for newer compression.

Now to your original question,

  1. You can definitely make it as web-api-like-app so developer can use it for batch compression/processing.
  2. User can apply filters via same API, for example grayscale image with 60% quality and 400 x 300 can be on the fly requested as pixxia-app.io/<image-uuid>?filter=gray&quality=60&width=400&height=300.

Let me know your thoughts.

Many powers.

Thread Thread
 
dhhruv profile image
Dhruv Panchal

Yeah, I've seen some engines like that. May work but still a lot of work has to be done from what you answered. Might wanna look into that. Thanks.

Collapse
 
rajmishra78 profile image
rajmishra78

Helped a lot. My 14 MB Image was Compressed to just 4 MB with almost no change in quality. Great Work.

Collapse
 
dhhruv profile image
Dhruv Panchal

Thanks. Glad I could help.

Collapse
 
dinhanhx profile image
dinhanhx

I am quite concerned about the way you import github.com/dhhruv/Pixxia/blob/6d9e...

Collapse
 
dhhruv profile image
Dhruv Panchal

Yeah, cleaning of the code is still in execution and we're still trying new things so haven't done yet.