I built a small utility: Image Compressor for HedgeDoc

Hi everyone,

I wanted to share a simple tool I built to help with image management in HedgeDoc deployments. It helps me keep the Docker Volume Filesize manageable when using the Server to Host the images.

What it does

The tool automatically compresses images that users upload to HedgeDoc to reduce storage usage and improve loading times. It runs in the background and:

  • Watches the uploads directory for new images
  • Compresses them using one of these formats (AVIF, WebP or JPEG)
  • Can be configured via env variables for Format, Maximum Dimension and Compression Rate

Why I made it

I was running out of storage on my small VPS due to uncompressed image uploads. Keeping the Images on the Server was best for Data Compliance - so i built this extra Container that runs in a HedgeDoc Stack.

How to use it

It’s available as a Docker container and simple to add to an existing HedgeDoc stack:

image-compress:
    image: ghcr.io/tiny-media/hedgedoc-image-compressor:latest
    container_name: hedgedoc-image-compress
    volumes:
        - hedgedoc_uploads:/hedgedoc/public/uploads
    restart: unless-stopped
    depends_on:
        - app
    environment:
        - OUTPUT_FORMAT=avif
        - REDUCTION_THRESHOLD=15
        - WEBP_QUALITY=75
        - AVIF_QUALITY=60
        - JPEG_QUALITY=75
        - MAX_DIMENSION=1600

You have to mount the same volume that HedgeDoc uses for uploads. All configuration is optional with my defaults.

You can find the project and a more detailed readme at: GitHub - tiny-media/hedgedoc-image-compressor: A simple image compressor container to run along Hedgedoc that compresses and converts images when uploaded to a Docker Volume.

Feedback and contributions welcome! I hope someone else finds this helpful.
Thank you for HedgeDoc
richard

2 Likes

Hi @richard, that’s a cool idea and seems like a useful utility. Thanks for sharing that!

Hi! Great stuff!
Will be testing that on my instance soon.