img Command Line Image Processor
img is a command line image processor, in the way of ImageMagick and G'MIC. It simply
provides a command line interface to the gimage library, exposing the tools with commands
that look like this:
img DSG_0001.NEF:rawdata=crop subtract:camera whitebalance:camera demosaic:ahd
blackwhitepoint:rgb,data tone:filmic resize:640,0 sharpen:1 DSG_0001.jpg
which opens the NEF as the raw data, subtracts the camera-supplied black value, whitebalances
the data with the camera-supplied multipliers, auto-adjusted black/white point to the data limits,
resize preserving aspect ratio, just a bit of sharpen, and saves to a JPEG. In the
Windows installers, you are queried regarding adding the path to img to the PATH variable;
if you intend to use img, that's a good idea.
img has acouple of batch tricks worth mentioning here:
img reads the rawproc configuration file in the default locations, first from
the current working directory of img, next from the application default. This allows img tools to
use the configured parameters of the respective rawproc tools, as well as the input parameters. Two
particular input parameters have special meaning:
- input.jpeg|tiff|png|raw.parameters: Applies the input parameters specified in the specified
property. For example,
img "*.NEF:input.raw.parameters" ...
retrieves the parameter string at input.raw.parameters property and uses them when each input image is opened.
- input.raw.libraw: This property tells img to round up all the input.raw.libraw parameters, construct
a parameter string from them, and use them to open each image.
These changes now allow img to construct output images that contain processing strings sufficient
to allow rawproc to open-source the image and reconstruct it from the original image. The following
workflow is possible:
- Shoot pictures in raw, all day
- At the end of the day, make a directory suitably named for the viewable images, and a subdirectory
under it for the raw files
- Copy the raw files to the raw file subdirectory
Open a command shell, cd to the raw directory, and run the img command at the top of this page.
This will produce viewable JPEGs in the parent directory, sized to 640px on their largest dimension, with
a full processing chain in their metadata
- At leisure, regard the JPEGs and select ones for re-processing if desired. If one is selected,
it can be opened by dragging it to a rawproc desktop shortcut; rawproc will find the processing chain
and ask if the original (raw) file is to be opened and re-processed. Say "yes", and the raw file is
opened, and the img processing chain is re-applied. You can now modify it at will for various
needs, such as creative cropping or resize for a different viewing situation, and save to a different
filename, or overwrite the original img-produced JPEG
img Tools
- add
- :<float> - Adds a float value to each image channel value.
- :<filename> - Adds a file containing a RGB image of the same dimensions.
- blackwhitepoint
- NULL - do auto on rgb.
- :rgb|red|green|blue - do auto on channel.
- :<nbr>,[<nbr>] - specific b/w on rgb, if only one number, b=, w=255.
- :rgb|red|green|blue,<nbr>[,<nbr>] - specific b/w on channel, if only one number, b=, w=255.
- :rgb|red|green|blue,data[,minwhite] - b/w on data limits, b=smallest r|g|b, w=largest r|g|b. If 'minwhite' is specified, use the smallest r|g|b for w.
- :camera - b/w on rgb using camera exif limits.
- colorspace
- :<profile_filename>[,assign|convert][,absolute_colorimetric|relative_colorimetric|perceptual|saturation][,bpc] - open profile file and use to assign|convert.
- :camera[,assign|convert][,absolute_colorimetric|relative_colorimetric|perceptual|saturation][,bpc] - find camera primaries in dcraw.c|camconst.json|libraw, make a d65 profile and use to assign|convert.
- :<int>,<int>,<int>,<int>,<int>,<int>,<int>,<int>,<int>[,assign|convert][,absolute_colorimetric|relative_colorimetric|perceptual|saturation][,bpc] - use 9 ints to make a d65 profile and use to assign|convert.
- :srgb|wide|adobe|prophoto|identity[,assign|convert][,absolute_colorimetric|relative_colorimetric|perceptual|saturation][,bpc] - use one of the built-in primary sets to make a d65 profile and use to assign|convert.
- :aces2065-1-v4-g10|adobergb-v4-g10| bt709-v4-g10|prophoto-v4-g10|rec2020-v4-g10|srgb-v4-g10|srgb-v2-g22| srgb-output[,assign|convert] - use one of the built-in ICC profiles to assign|convert.
- crop:<x1>,<y1>,<x2>,<y2> | camera - extract subimage at top,left,bottom,right bounds and make the new image. can be either int coords or 0.0-1.0 proportions to w|h. 'camera' builds a crop box from raw metadata.
- cropspectrum:<boundint>,<thresholdfloat> - Finds the brightest green pixel based on the 0.0-1.0 threshold and crops the image to the rows boundint/2 above and boundint/2 below. Used to extract data from images of spectra.
- curve:rgb|red|green|blue,<x1>,<y1>,...,<xn>,<yn> - apply curve to the designated channel defined by the x,y coordinates, 0-255
- demosaic
- :color - color the unmosaiced Bayer image with the pattern colors. A teaching tool; not for further processing.
- :half|half_resize|vng|rcd|igv|ahd|xtrans_fast - demosaic the Bayer image.
- :dcb[,<iterations>][,dcb_enhance] - demosaic the Bayer image with the supplied parameters.
- :amaze[,<initgain>][,<border>] - demosaic the Bayer image with the supplied parameters.
- :lmmse[,<iterations] - demosaic the Bayer image with the supplied parameters.
- :xtrans_markesteijn[,<passes>][,usecielab] - demosaic the XTrans image with the supplied parameters.
- :proof - xtrans_fast or half, depending on image type (XTrans|bayer).
- denoise
- :nlmeans[,<sigma>][,<local>][,<patch>][,<threshold>] - apply nlmeans denoise.
- :wavelet[,<threshold>] - apply wavelet denoise.
- exposure
- :<ev> - apply the ev to the image.
- :patch,x,y,r,ev0 - Compute what it would take to make the value at the patch coorinates the value of ev0, then apply that EV to the entire image.
- gray
- :<redfloat>,<greenfloat>,<bluefloat> - grayscale the image using the specified RGB multipliers.
- :NULL - grayscale the image using the default multipliers.
- hlrecover
- no parameters - use after whitebalance and demosaic to mitigate stacked data due to blown highlights
- lenscorrection Apply the specified lens corrections (ca,vig,dist,autocrop) using the lensfun data for that lens. algo applies to dist and ca
- :([ca][,vig][,dist][,autocrop])[,nearest|bilinear|lanczos3],[reticlinear|fisheye|panoramic|equirectangular|orthographic|stereographic|equisolid|thoby) - positional format.
- :ops=...[;algo=nearest|bilinear|lanczos3][,geometry=reticlinear|fisheye|panoramic|equirectangular|orthographic|stereographic|equisolid|thoby - param=value format.
- redeye: <xint1>,<yint1>[,<xint2>,<yint2>...],<tint>,<lint> - Apply redeye correction at the points specified by xn,yn with the specified threshold and limit (limit is a radius) (img can only specify one x,y).
- resize:[,][,box|bilinear|bspline|bicubic|catmullrom|lanczos3] -
resize the image to the specified width and height, using the specified interpolation algorithm.
If only one number is provided, use it for the largest dimension and compute the other to preserve
the aspect ratio (0 is passed to the Apply function and it does the aspect computation).
- rotate:<rfloat> |hmirror|vmirror - rotate the image. rrotate can be -45.0-+45.0, 90, 180, or 270.
- saturation:[rgb|red|green|blue],<saturationfloat>[,<thresholdfloat> ] - apply HSL saturation to the image in the amount specified. If channel is specified, restrict application to it; if threshold is specified (not used for rgb), restrict application to only values above it.
- script:program,scriptfile - Use the program and corresponging script file to modify the image. Note: Currently only implemented in rawproc; img won't recognize the tool.
- sharpen
- :usm[,<sfloat>][,<rfloat>] - apply usm sharpen with the specified sigma and radius.
- :convolution[,<afloat>] - apply convolution sharpen with the specified amount.
- :<afloat> - apply convolution sharpening with the specified amount.
- subtract
- subtract
- :<float> - Subtracts a float value to each image channel value.
- :<filename> - Subtracts a file containing a RGB image of the same dimensions.
- :camera - subtract the metadata-extracted black value, global (img and rawproc), perchannel (rawproc), or cfa (rawproc).
- tone - applies a non-linear tone curve to the image. One of:
- :gamma[,<gfloat>]
- :reinhard,channel|luminance[,norm]
- :log2
- :loggamma
- :lut,lutfile
- :filmic[,<Afloat>,<Bfloat>,<Cfloat>,<Dfloat>][,<pfloat>][,norm]
- whitebalance
- :camera - apply white balance from the camera metadata multipliers, "as-shot."
- :auto - apply auto (gray world) white balance.
- :patch,<xint>,<yint>,<rfloat> - apply white balance calculated from the patch at x,y of radius r.
- :<rfloat>,<gfloat>,<bfloat> - apply white balance with the specified RGB multipliers.