diff --git a/crop.py b/crop.py index 01e1f36..b33a706 100644 --- a/crop.py +++ b/crop.py @@ -7,6 +7,7 @@ from voussoirkit import pipeable def crop(file, crops, *, inplace=False, quality=100): image = PIL.Image.open(file.absolute_path) + icc_profile = image.info.get('icc_profile') if len(crops) == 2: crops.extend(image.size) @@ -27,7 +28,7 @@ def crop(file, crops, *, inplace=False, quality=100): newname = file.parent.with_child(base + suffix).add_extension(file.extension) pipeable.stdout(newname.absolute_path) - image.save(newname.absolute_path, exif=image.getexif(), quality=quality) + image.save(newname.absolute_path, exif=image.getexif(), quality=quality, icc_profile=icc_profile) def crop_argparse(args): patterns = pipeable.input(args.pattern, skip_blank=True, strip=True) diff --git a/rejpg.py b/rejpg.py index 50c5466..453d4f9 100644 --- a/rejpg.py +++ b/rejpg.py @@ -54,6 +54,7 @@ def rejpg_argparse(args): for filename in files: log.info('Processing %s.', filename) image = PIL.Image.open(filename) + icc_profile = image.info.get('icc_profile') (image, exif) = imagetools.rotate_by_exif(image) @@ -62,7 +63,7 @@ def rejpg_argparse(args): bytesio = compress_to_filesize(image, target_size, exif=exif) else: bytesio = io.BytesIO() - image.save(bytesio, format='jpeg', exif=exif, quality=args.quality) + image.save(bytesio, format='jpeg', exif=exif, quality=args.quality, icc_profile=icc_profile) bytesio.seek(0) new_bytes = bytesio.read() diff --git a/resize.py b/resize.py index f0e9bc4..113ce75 100644 --- a/resize.py +++ b/resize.py @@ -32,6 +32,7 @@ def resize( file = pathclass.Path(filename) image = PIL.Image.open(file.absolute_path) + icc_profile = image.info.get('icc_profile') (image, exif) = imagetools.rotate_by_exif(image) (image_width, image_height) = image.size @@ -110,7 +111,7 @@ def resize( if output_file.extension == '.jpg': image = image.convert('RGB') - image.save(output_file.absolute_path, exif=exif, quality=quality) + image.save(output_file.absolute_path, exif=exif, quality=quality, icc_profile=icc_profile) return output_file def resize_argparse(args): diff --git a/rotate.py b/rotate.py index 310e887..17eff41 100644 --- a/rotate.py +++ b/rotate.py @@ -19,6 +19,7 @@ def rotate_argparse(args): for file in files: image = PIL.Image.open(file.absolute_path) + icc_profile = image.info.get('icc_profile') if args.exif: (new_image, exif) = imagetools.rotate_by_exif(image) @@ -43,7 +44,7 @@ def rotate_argparse(args): newname = file.parent.with_child(newname).add_extension(file.extension) pipeable.stdout(newname.absolute_path) - image.save(newname.absolute_path, exif=exif, quality=args.quality) + image.save(newname.absolute_path, exif=exif, quality=args.quality, icc_profile=icc_profile) @vlogging.main_decorator def main(argv):