pyguymer3.image.image2png

pyguymer3.image.image2png(img, png, /, *, chunksize=1048576, debug=True, exif=None, exiftoolPath=None, gifsiclePath=None, jpegtranPath=None, mode='RGB', optimise=True, optipngPath=None, screenHeight=-1, screenWidth=-1, strip=False, timeout=60.0)[source]

Save an image as a PNG

This function accepts either a PIL Image or a file path and saves the image as a PNG.

Parameters:
  • img (PIL.Image.Image or str) – the input PIL Image or path to the input image

  • png (str) – the path to the output PNG

  • chunksize (int, optional) – the size of the chunks of any files which are read in (in bytes)

  • debug (bool, optional) – print debug messages (default False)

  • exif (dict, optional) – a dictionary of EXIF data to save in the output PNG (default None)

  • exiftoolPath (str, optional) – the path to the “exiftool” binary (if not provided then Python will attempt to find the binary itself)

  • gifsiclePath (str, optional) – the path to the “gifsicle” binary (if not provided then Python will attempt to find the binary itself)

  • jpegtranPath (str, optional) – the path to the “jpegtran” binary (if not provided then Python will attempt to find the binary itself)

  • mode (str, optional) – the mode of the outout PNG (default “RGB”)

  • optimise (bool, optional) – optimise the output PNG (default True)

  • optipngPath (str, optional) – the path to the “optipng” binary (if not provided then Python will attempt to find the binary itself)

  • screenHeight (int, optional) – the height of the screen to downscale the input image to fit within, currently only implemented if “img” is a str (default -1; integers less than 100 imply no downscaling)

  • screenWidth (int, optional) – the width of the screen to downscale the input image to fit within, currently only implemented if “img” is a str (default -1; integers less than 100 imply no downscaling)

  • strip (bool, optional) – strip metadata from the output PNG (default False)

  • timeout (float, optional) – the timeout for any requests/subprocess calls

Notes

Copyright 2017 Thomas Guymer [1]

References