pyguymer3.image.image2jpg

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

Save an image as a JPG

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

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

  • jpg (str) – the path to the output JPG

  • 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 JPG (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 JPG (default “RGB”)

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

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

  • progressive (bool, optional) – save a progressive JPG (default False)

  • quality (int, optional) – the quality of the output JPG (default 95)

  • 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 JPG (default False)

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

Notes

Copyright 2017 Thomas Guymer [1]

References