Skip to content

Instantly share code, notes, and snippets.

View LeFanch's full-sized avatar

Fañch LeFanch

View GitHub Profile
@LeFanch
LeFanch / gist:3a4de05f59412ff1f2384bea04687e69
Last active October 23, 2023 09:47
Keep metadata of image optimized by mozjpeg_lossless_optimization, with piexif
import mozjpeg_lossless_optimization
import piexif
src_file = "source_image.jpg"
out_file = "optimized.jpg"
# Open image
with open(src_file, "rb") as input_jpeg_file:
input_jpeg_bytes = input_jpeg_file.read()