Skip to content

A Simple Logo Standardizer Bash Script with Imagemagick

License

Notifications You must be signed in to change notification settings

geekdinazor/stdlogo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

stdlogo

This script standardizes the size of images, particularly brand logos, across various formats, aspect ratios, and sizes. It resizes the source image to the desired dimensions and centers it within a larger frame of the specified size, filling the background with the chosen color.

Features

  • Process images with different formats (JPG, JPEG, PNG, SVG, WEBP).
  • Batch processing for directories of images.
  • Resize and trim images with customizable parameters.
  • Set background color and extend images to specified dimensions.

Options

  • -i, --input <file_or_directory>: Input file or directory. Required.
  • -o, --output <directory>: Output directory. Required.
  • --fuzz <percentage>: Fuzz percentage for trimming the image. Useful when work with some low quality JPEGs. Default is 0.
  • --width <width>: Output image width. Default is 400.
  • --height <height>: output image height. Default is 230.
  • --tolerance <tolerance>: Height tolerance for scaling. Default is 0.
  • --logo-width <width>: Width of the logo. Default is 230.
  • --logo-height <height>: Height of the logo. Default is 85.
  • --background <color>: Background color to use. Default is white.
  • --workdir <directory>: Temporary working directory. Default is a temporary directory created by the script.
  • --batch: Enable batch processing mode for directories.
  • -q, --quiet: Suppress log messages.

Usage

To protect aspect ratio, two strategies used for expanding logo:

If (desired logo width / original logo width) * original logo height smaller than desired logo height + tolerance (in px), logo will resized to desired height, otherwise logo will resized to desired width.

You can run stdlogo.sh directly from the command line with various options.

Basic Usage

To process a single image:

bash stdlogo.sh -i input_image.png -o output_directory --fuzz 10 --width 400 --height 230 --tolerance 10 --logo-width 230 --logo-height 85 --background white

Batch Mode

To process all images in a directory:

bash stdlogo.sh -i input_directory -o output_directory --batch --fuzz 10 --width 400 --height 230 --tolerance 10 --logo-width 230 --logo-height 85 --background white

Requirements

  • ImageMagick: Required for image processing tasks.
  • awk: Required for mathematical calculations.
  • mktemp: Required for creating temproary directories.

Example

You can see the demo here.

Limitations

  • The script does not remove background colors. For logos with solid backgrounds, use background removal services like remove.bg.
  • High values for --fuzz may cause distortions in logos.
  • Some logos with solid backround may be over-trimmed.

Notes

The original script was written in March 2021.

License

This script is provided under the MIT License. See the LICENSE file for more details.

About

A Simple Logo Standardizer Bash Script with Imagemagick

Resources

License

Stars

Watchers

Forks

Languages