Skip to content

jhewlett/BatchEdit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BatchEdit



Introduction:

BatchEdit is a python application for easily editing photos in batch. It has a simple command-line interface that will be familiar to UNIX users.

Prerequisites:

  • Python 3.9

  • Pillow 10.0.1

Installation and Usage:

  1. Ensure that the prerequisites are met. The application may work with earlier version of Python or PIL, but no guarantee.

  2. Copy the BatchEdit.zip file to a location of your choice.

  3. From a command prompt, type the following:

python [path to BatchEdit]\BatchEdit.zip --input [input folder] --output [output folder] [other options]

  1. To get a list of all available options, type --help.

Note that there is no need to unzip the ‘BatchEdit.zip’ file.

Command-line Options:

The following command-line options are available to tweak the settings and specify operations to perform on all of the images.

Settings:

--input [path]: A directory with images to process (required). If the directory contains spaces, be sure to enclose it in double quotes.

--output [path]: A directory to output the process images to (required). The directory must exist. Enclose the directory in double quotes if needed.

--quality [value]: An integer from 1 - 100 indicating the quality of the output image. Defaults to 95.

--files [filters]: String representing the UNIX glob pattern. Supports ‘[ ]’ character ranges, ‘?’ and ‘*’. Defaults to '*.jpg'. On Linux, be sure to enclose the filters in quotes to prevent it from expanding in place.

--forceorder: A flag indicating whether the commands should be executed exactly in the order typed. Defaults to false.

Photo Operations:

Many of the filters take a decimal argument for the strength. A value of 1 returns the original image. A value less than 1 will decrease the effect, while a value greater will increase it. With the exception of --watermark, all of the arguments are optional.

--sharpen [strength]: Blurs or sharpens the image according to the strength. Defaults to 1.3.

--contrast [strength]: Decreases or increases contrast based on the strength provided. Defaults to 1.15.

--brightness [strength]: Decreases or increases brightness based on the strength provided. Defaults to 1.

--saturation [strength]: Decreases or increases the vibrancy of the color. Defaults to 1.15.

--grayscale: Converts the image to grayscale.

--autorotate: Reads the exif tags of the image, if available, and attempts to auto-rotate the image accordingly. When used in conjunction with --forceorder, --autorotate must be the first operation in order to work.

--resize [longest side]: Resizes the longest dimension in the image to the value specified. Maintains the aspect ratio. When provided, expects the argument to be an integer. Defaults to 640 pixels. Note that --resize does not take into account border sizes. For example, if you resize to 640 pixels and add a border with a thickness of 5, the resulting image size will be 640 + 5 + 5 = 650 pixels.

--border [thickness[,color]]: Draws a border with the thickness and color specified on all sides. The thickness should be a positive whole number. The color should be a text description, such as “black” or “red.” Defaults to 10 pixels with a fill of black.

--watermark [path to image]: Overlays the specified image in the lower middle as a watermark. The argument expects a path to the file to overlay (required). Supports transparency.

Order of Operations:

Operations happen in the following order:

First:

--autorotate

Second:

--contrast
--saturation
--brightness
--grayscale

Third:

--resize

Last:

--sharpen
--border
--watermark

Operations within the same group will happen in the order typed. To force all operations to happen in the order typed, regardless of these groupings, use the --forceorder option.

Examples:

  1. We want to auto rotate, increase contrast, convert to grayscale, resize to 720 pixels, sharpen, add a gray border of 5 pixels, and overlay a watermark.

python scripts\BatchEdit.zip --input C:\input --output C:\output --autorotate
--resize 720 --grayscale --contrast --sharpen 1.3 --border 5,gray
--watermark C:\logo_transparent.png

Note that because we left out the --contrast argument, it will default to 1.15.

  1. We want to only look for .jpg files starting with “IMG_” in our input folder. We want to set the quality to 70. We want to blur the image and add a thick red border before resizing. To prevent the application from re-ordering our operations, we will use the --forceorder option.

python scripts\BatchEdit.zip --input C:\input --output C:\output
--files ‘IMG_*.jpg’ --quality 70 --sharpen .5 --border 20,red --brightness 1.2
--resize --forceorder

Note that because we left out the --resize parameter, it will default to 640 pixels.

About

A command-line tool for batch editing photos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages