LinuxCommandLibrary

imgp

Resize and optimize images

TLDR

Convert single images and/or whole directories containing valid image formats

$ imgp [[-x|--res]] [1366x1000] [path/to/directory] [path/to/file]
copy

Scale an image by 75% and overwrite the source image to a target resolution
$ imgp [[-x|--res]] [75] z-w [path/to/file]
copy

Rotate an image clockwise by 90 degrees
$ imgp [[-o|--rotate]] [90] [path/to/file]
copy

SYNOPSIS

imgp [OPTIONS]
imgp --help
imgp --version

PARAMETERS

--recursive, -r
    Process images in subdirectories recursively.

--output

, -o
    Specify the output directory. Defaults to 'imgp_out' or current directory.

--quality , -q
    Set the output quality for lossy formats (e.g., JPEG, WebP) from 1 to 100.

--size , -s
    Resize images. Examples: 1920x1080, 50%, 1200x, x900.

--mode , -m
    Resizing mode: contain (default, fit within bounds), cover, crop, stretch.

--format , -f
    Convert output format (e.g., jpeg, png, webp).

--verbose, -v
    Display verbose output during processing.

--no-metadata
    Strip all EXIF, ICC, and other metadata from images.

--auto-rotate
    Automatically rotate images based on EXIF orientation data.

--max-files
    Limit the number of files to process.

--log-file
    Write detailed log information to a specified file.

--preserve-filenames
    Keep original filenames in the output directory.

--skip-existing
    Skip processing if an identically named output file already exists.

--skip-larger
    Skip processing if the output file would be larger than the input.

--skip-compressed
    Skip processing if the image is already highly compressed (e.g., JPEG quality < 80).

--suffix
    Add a suffix to the output filenames.

--prefix
    Add a prefix to the output filenames.

--lower
    Convert output filenames to lowercase.

--upper
    Convert output filenames to uppercase.

--flatten
    Output all images directly into the output directory, ignoring input directory structure.

--strip-icc
    Strip ICC color profiles from images.

--keep-mtime
    Preserve the modification time of the original files for the output files.

--replace
    Replace input files with processed output files. Use with caution.

--help, -h
    Show help message and exit.

--version, -V
    Show program's version number and exit.

DESCRIPTION

imgp is a versatile command-line utility designed for efficient batch processing of images. It allows users to perform various operations such as resizing, compressing, converting formats, and stripping metadata from image files. Written in Python, imgp excels at handling large collections of images, making it ideal for web developers, photographers, and anyone needing to optimize or standardize image assets quickly. It supports recursive processing of directories and offers fine-grained control over output quality, dimensions, and file naming conventions. imgp aims to simplify common image manipulation tasks without requiring a graphical interface, providing a lightweight yet powerful alternative for command-line enthusiasts. Its core strength lies in its ability to automate repetitive image processing workflows.

CAVEATS

imgp relies on Python and the Pillow (PIL Fork) library for image processing, so these dependencies must be installed. While powerful for batch operations, it may not offer the same low-level pixel manipulation capabilities or exhaustive format support as larger suites like ImageMagick. Some advanced operations might require chained commands or external tools. Using the --replace option should be done with caution, as it overwrites original files.

<B>BATCH PROCESSING</B>

imgp excels at processing multiple files or entire directories recursively, making it highly efficient for optimizing large image collections. It automatically handles file naming and output directory structures unless specified otherwise.

<B>SUPPORTED FORMATS</B>

imgp primarily supports popular raster image formats including JPEG, PNG, WebP, and GIF. While it can read other formats supported by Pillow, its core optimization features are most effective with JPEGs and PNGs.

<B>ERROR HANDLING</B>

The command provides clear error messages for invalid inputs or processing failures. When processing multiple files, it attempts to continue with the next image even if one fails, logging the issues.

HISTORY

imgp emerged as a modern, user-friendly command-line tool primarily written in Python. Its development was likely driven by the need for a simpler, more accessible batch image processing utility compared to the often complex syntax of traditional tools like ImageMagick, particularly for common tasks such as resizing and compression. Being open-source, it benefits from community contributions and is actively maintained, focusing on ease of use and efficient performance for standard image optimization workflows. It has gained popularity among users looking for a lightweight, dependency-minimal solution that integrates well into shell scripts.

SEE ALSO

convert(1), mogrify(1), cjpeg(1), djpeg(1), jpegtran(1), optipng(1), pngcrush(1), exiftool(1)

Copied to clipboard