DEV Community

Karim
Karim

Posted on

Streamline Your Local Image Conversions and Compression With Docker and imgcompress

Image description

Hello, I am Karim Zouine, and I created this Docker-based tool called imgcompress because I got tired of relying on multiple programs whenever I needed to convert or compress images. Dealing with HEIC files was especially frustrating, since they often need specific DLLs that can be complicated to install. Although there are online conversion services out there, I have always been cautious about uploading personal photos to random websites. Privacy matters to me, so I wanted a reliable way to handle everything locally on my own computer.

By packaging imgcompress in a Docker container, I eliminated the need to install extra dependencies or spend time on complicated setup. Docker guarantees that imgcompress operates the same way on any machine, removing the guesswork. With just a few commands, it can also convert entire folders of images in one go.


Why imgcompress Matters To Me

  1. Local Conversion I prefer knowing my photos remain on my personal machine, rather than uploading them to external services. imgcompress makes this easy by running entirely locally.
  2. No More Extra DLLs HEIC files can be tricky because of the DLLs they require. With Docker, all the necessary libraries are included, so there is no need for extra installation steps.
  3. All In One Tool I grew tired of juggling multiple programs just to resize, compress, or convert images. Now, I simply point imgcompress at a folder (or a single file) and it handles everything with a single command.
  4. Easy To Use Docker makes the workflow straightforward. I mount my local image folder into the container, specify the quality and size, and let imgcompress do all the heavy lifting.

Getting Started

  1. Install Docker if you have not already done so.

  2. Pull the latest version of imgcompress:

   docker pull karimz1/imgcompress:latest
Enter fullscreen mode Exit fullscreen mode
  1. Run the container, mapping your local directories as needed.

Example For A Single File

docker run --rm \
  -v "$(pwd):/container/images" \
  -v "$(pwd)/converted:/container/converted" \
  karimz1/imgcompress:latest \
  /container/images/example.jpg /container/converted --quality 80 --width 1920
Enter fullscreen mode Exit fullscreen mode

This command tells Docker to:

  • Take a local file (example.jpg) and load it into the container.
  • Convert and compress it with a quality setting of 80.
  • Resize the image to a width of 1920 pixels (keeping aspect ratio).
  • Save the processed file in the local converted folder.

Example For An Entire Folder

 docker run --rm \
  -v "$(pwd):/container/images" \
  -v "$(pwd)/converted:/container/converted" \
  karimz1/imgcompress:latest \
  /container/images /container/converted --quality 85 --width 800
Enter fullscreen mode Exit fullscreen mode

This command processes every image in the images folder, then saves the results in the converted folder.


Keeping Things Open Source

I believe in sharing tools that address common challenges, so I made this project open source. If you would like to review the code, suggest improvements, or open issues, feel free to visit the GitHub repository. I appreciate any feedback or ideas.


Use In Automated Pipelines

imgcompress also shines in automated pipelines. If you have a continuous integration or deployment process, you can integrate imgcompress to optimize images before they go live. It supports JSON logging, which makes it easy to track which images were processed successfully. This structured output can fit seamlessly into automated scripts and logging systems.


Privacy And Security

One of my main motivations was maintaining full control over my images. Because imgcompress runs in Docker on your local environment, there is no need to upload your images to a third-party website. This approach not only preserves your privacy but also avoids potential security risks that come with web-based tools.


If You Find This Useful

I am thrilled to offer this tool for free, and I truly value open source. If imgcompress saves you time or simplifies your workflow, you are welcome to support the project with a small donation. It is totally optional, and I appreciate your interest regardless.

PayPal: mails.karimzouine@gmail.com


Thank you for taking the time to learn about imgcompress. I hope it makes your image conversion tasks easier and more secure. Give it a try, and feel free to share your experience or contribute your ideas to help improve it for everyone. ❤️

Top comments (0)