From db6238346f7c9c69c1131c46abdfaad996ebc570 Mon Sep 17 00:00:00 2001 From: Lilo Huang Date: Mon, 3 Apr 2023 07:54:44 +0800 Subject: [PATCH] Add copynone option to crop_multiple #68 (#69) * Add copynone option to crop_multiple (#68) Allows to avoid copy of EXIF data when generating multiples crops. --------- Co-authored-by: Christian Quest --- LICENSE | 2 +- setup.py | 2 +- turbojpeg.py | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/LICENSE b/LICENSE index e6ba98d..71a1c98 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2022 Lilo Huang +Copyright (c) 2018-2023 Lilo Huang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/setup.py b/setup.py index 09464a5..2a9ae49 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='PyTurboJPEG', - version='1.7.0', + version='1.7.1', description='A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.', author='Lilo Huang', author_email='kuso.cc@gmail.com', diff --git a/turbojpeg.py b/turbojpeg.py index e2d57fc..17d0c8b 100644 --- a/turbojpeg.py +++ b/turbojpeg.py @@ -2,7 +2,7 @@ # # PyTurboJPEG - A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image. # -# Copyright (c) 2018-2022, Lilo Huang. All rights reserved. +# Copyright (c) 2018-2023, Lilo Huang. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ # SOFTWARE. __author__ = 'Lilo Huang ' -__version__ = '1.7.0' +__version__ = '1.7.1' from ctypes import * from ctypes.util import find_library @@ -587,7 +587,7 @@ def crop(self, jpeg_buf, x, y, w, h, preserve=False, gray=False): finally: self.__destroy(handle) - def crop_multiple(self, jpeg_buf, crop_parameters, background_luminance=1.0, gray=False): + def crop_multiple(self, jpeg_buf, crop_parameters, background_luminance=1.0, gray=False, copynone=False): """Lossless crop and/or extension operations on jpeg image. Crop origin(s) needs be divisable by the MCU block size and inside the input image, or OSError: Invalid crop request is raised. @@ -604,6 +604,8 @@ def crop_multiple(self, jpeg_buf, crop_parameters, background_luminance=1.0, gra Default to 1, resulting in white background. gray: bool Produce greyscale output + copynone: bool + True = do not copy EXIF data (False by default) Returns ---------- @@ -659,7 +661,7 @@ def crop_multiple(self, jpeg_buf, crop_parameters, background_luminance=1.0, gra crop_transforms[i] = TransformStruct( crop_region, TJXOP_NONE, - TJXOPT_PERFECT | TJXOPT_CROP | (gray and TJXOPT_GRAY), + TJXOPT_PERFECT | TJXOPT_CROP | (gray and TJXOPT_GRAY) | (copynone and TJXOPT_COPYNONE), pointer(callback_data), callback ) @@ -667,7 +669,7 @@ def crop_multiple(self, jpeg_buf, crop_parameters, background_luminance=1.0, gra crop_transforms[i] = TransformStruct( crop_region, TJXOP_NONE, - TJXOPT_PERFECT | TJXOPT_CROP | (gray and TJXOPT_GRAY) + TJXOPT_PERFECT | TJXOPT_CROP | (gray and TJXOPT_GRAY) | (copynone and TJXOPT_COPYNONE) ) # Pointers to output image buffers and buffer size