Sign inSign up

okngroup/image-conversion

By okngroup

•Updated over 2 years ago

Image
0

1.2K

okngroup/image-conversion repository overview

⁠Docker Image: Image Conversion

This Docker image allows you to convert images to WebP format using ImageMagick, libwebp-tools, and parallel in an Alpine Linux environment.

⁠Usage

To use this Docker image, follow the instructions below:

Run the Docker Container


docker run -v /path/to/images:/images -e IMAGE_SIZE=1024x768 -e CONVERT_TO_WEBP=true -e RESIZE_IMAGES=all okngroup/image-conversion

Replace /path/to/images with the actual path to the directory containing the images you want to process.

⁠Environment Variables

The Docker image supports the following environment variables:

  • IMAGE_SIZE (default: 1024x768): Specifies the desired size for resizing the images. The format should be in width x height (e.g., 800x600).

  • CONVERT_TO_WEBP (default: true): Specifies whether to convert the images to WebP format. Set to true to enable WebP conversion.

  • RESIZE_IMAGES (default: bigger): Specifies which images to resize. Possible values are:

  - true: Resize all images to the specified IMAGE_SIZE.

  - bigger: Only resize images larger than the IMAGE_SIZE.

  - smaller: Only resize images smaller than the IMAGE_SIZE.

  - all: Resize all images regardless of their size.

You can customize these variables by setting them when running the Docker container using the -e option followed by the variable name and value.

⁠Docker Compose

To use this Docker image in a Docker Compose file, follow the example below:

docker-compose.yml


version: '3'

services:

  image-conversion:

    image: okngroup/image-conversion

    volumes:

      - /path/to/images:/images

    environment:

      - IMAGE_SIZE=1024x768

      - CONVERT_TO_WEBP=true

      - RESIZE_IMAGES=all

Replace /path/to/images with the actual path to the directory containing the images you want to process.

Save the above content to a file named docker-compose.yml, then run the following command:


docker-compose up

This will start the container and perform the image conversion based on the specified configuration.

⁠Details

The Docker image is based on Alpine Linux and includes the following components:

  • ImageMagick: Used for image resizing.

  • libwebp-tools: Used for WebP image conversion.

  • parallel: Used for parallel execution of image conversion.

  • bash: Required for running the script.

The conversion process is automated using the convert_images script, which is copied into the container. The script is made executable, and a symbolic link is created in the /usr/local/bin directory for ease of use.

The entry point of the container is set to the convert_images script, which takes the /images directory as an argument. Make sure to mount the appropriate directory containing the images you want to convert using the -v option when running the Docker container.

Tag summary

Content type

Image

Digest

sha256:0e12c5e2e…

Size

57.5 MB

Last updated

over 3 years ago

docker pull okngroup/image-conversion