pyguymer3.image

A Python sub-module containing a bunch of random image-related functions that I have written over the years. If you want to use some of these functions directly from the command line then you can run python3.12 -m pyguymer3.image --help to see what is available.

Notes

Copyright 2017 Thomas Guymer [1]

References

Modules

EXIF_datetime(info, /, *[, debug, maxDOP, ...])

dict2exif(exif, /, *[, mode])

Convert a dictionary to an EXIF class

dot2png(dot, png, /, *[, chunksize, debug, ...])

chunksize : int, optional

exiftool(fname, /, *[, exiftoolPath, timeout])

"exiftool" does not modify, and it does not touch, the image even if it cannot strip anything, therefore it is safe to keep on running "exiftool" on the same image over and over again.

gifsicle(fname1, /, *[, chunksize, debug, ...])

"gifsicle" does modify, and it does touch, the image even if it cannot make it smaller, therefore it is NOT safe to keep on running "gifsicle" on the same GIF over and over again.

image2gif(img, gif, /, *[, chunksize, ...])

Save an image as a GIF

image2jpg(img, jpg, /, *[, chunksize, ...])

Save an image as a JPG

image2png(img, png, /, *[, chunksize, ...])

Save an image as a PNG

image2webp(img, webp, /, *[, exif, ...])

Save an image as a WEBP

is_image_animated(fName, /, *[, cacheDir, ...])

jpegtran(fname1, /, *[, chunksize, debug, ...])

"jpegtran" does not modify, but it does touch, the image even if it cannot make it smaller, therefore it is NOT safe to keep on running "jpegtran" on the same JPG over and over again.

load_EXIF(fName, /, *[, cacheDir, ...])

Run the "exifread" module or the "exiftool" binary on a file and return the metadata.

load_GPS_EXIF(fName, /, *[, cacheDir, ...])

load_GPS_EXIF1(fName, /, *[, cacheDir, ...])

load_GPS_EXIF2(fName, /, *[, cacheDir, ...])

makePng(arrUint8, /, *[, calcAdaptive, ...])

Make a PNG

makePngSrc

A Python sub-module containing a functions used in making PNG images that I have written over the years.

manuallyOptimisePng(pName, /, *[, ...])

Manually optimise a PNG image.

optimise_image(fname, /, *[, chunksize, ...])

Please read the documentation for the four functions: "exiftool", "gifsicle", "jpegtran" and "optipng".

optipng(fname, /, *[, optipngPath, pool, ...])

"optipng" does not modify, and it does not touch, the image even if it cannot make it smaller, therefore it is safe to keep on running "optipng" on the same PNG over and over again.

returnPngInfo(pName, /, *[, debug])

Return information about a PNG

return_image_bit_depth(fName, /, *[, ...])

return_image_format(fName, /, *[, cacheDir, ...])

return_image_height(fName, /, *[, cacheDir, ...])

return_image_mode(fName, /, *[, cacheDir, ...])

return_image_size(fName, /, *[, cacheDir, ...])

return_image_width(fName, /, *[, cacheDir, ...])

rgb2hlsComp(r, g, b, /)

This function returns the HLS complementary colour of an RGB triplet.

rgb2name(r, g, b, /)

This function says if one channel is brighter than the others in an RGB triplet.

rgb2rgbComp(r, g, b, /)

This function returns the RGB complementary colour of an RGB triplet.

save_array_as_PGM(img, fname, /)

Save an array as a PGM image.

save_array_as_PNG(arrUint8, fname, /, *[, ...])

Save an array as a PNG image.

save_array_as_PPM(img, fname, /)

Save an array as a PPM image.

save_array_as_image(img0, fname, /, *[, ...])

Save an array as an image