Closed Zebrafish007 closed 4 years ago
While using the code provided as below I wanted to change the thumbnail into some monthy python fun image but the script won't do it if I open the image.
import io from PIL import Image import piexif
o = io.BytesIO() thumb_im = Image.open("Q:\M\monty-truth.png'") thumb_im.thumbnail((100, 100), Image.ANTIALIAS) thumb_im.save(o, "jpeg") thumbnail = o.getvalue()
zeroth_ifd = {piexif.ImageIFD.Make: u"Canon", piexif.ImageIFD.XResolution: (96, 1), piexif.ImageIFD.YResolution: (96, 1), piexif.ImageIFD.Software: u"piexif" } exif_ifd = {piexif.ExifIFD.DateTimeOriginal: u"2099:09:29 10:10:10", piexif.ExifIFD.LensMake: u"LensMake", piexif.ExifIFD.Sharpness: 65535, piexif.ExifIFD.LensSpecification: ((1, 1), (1, 1), (1, 1), (1, 1)), } gps_ifd = {piexif.GPSIFD.GPSVersionID: (2, 0, 0, 0), piexif.GPSIFD.GPSAltitudeRef: 1, piexif.GPSIFD.GPSDateStamp: u"1999:99:99 99:99:99", } first_ifd = {piexif.ImageIFD.Make: u"Canon", piexif.ImageIFD.XResolution: (40, 1), piexif.ImageIFD.YResolution: (40, 1), piexif.ImageIFD.Software: u"piexif" }
exif_dict = {"0th":zeroth_ifd, "Exif":exif_ifd, "GPS":gps_ifd, "1st":first_ifd, "thumbnail":thumbnail} exif_bytes = piexif.dump(exif_dict) im = Image.open("Q:\M\beefeater.jpg") im.thumbnail((2000, 2000), Image.ANTIALIAS) im.save("out.jpg", exif=exif_bytes)
Windows 10 Issue.... so nevermind.
While using the code provided as below I wanted to change the thumbnail into some monthy python fun image but the script won't do it if I open the image.
import io from PIL import Image import piexif
o = io.BytesIO() thumb_im = Image.open("Q:\M\monty-truth.png'") thumb_im.thumbnail((100, 100), Image.ANTIALIAS) thumb_im.save(o, "jpeg") thumbnail = o.getvalue()
zeroth_ifd = {piexif.ImageIFD.Make: u"Canon", piexif.ImageIFD.XResolution: (96, 1), piexif.ImageIFD.YResolution: (96, 1), piexif.ImageIFD.Software: u"piexif" } exif_ifd = {piexif.ExifIFD.DateTimeOriginal: u"2099:09:29 10:10:10", piexif.ExifIFD.LensMake: u"LensMake", piexif.ExifIFD.Sharpness: 65535, piexif.ExifIFD.LensSpecification: ((1, 1), (1, 1), (1, 1), (1, 1)), } gps_ifd = {piexif.GPSIFD.GPSVersionID: (2, 0, 0, 0), piexif.GPSIFD.GPSAltitudeRef: 1, piexif.GPSIFD.GPSDateStamp: u"1999:99:99 99:99:99", } first_ifd = {piexif.ImageIFD.Make: u"Canon", piexif.ImageIFD.XResolution: (40, 1), piexif.ImageIFD.YResolution: (40, 1), piexif.ImageIFD.Software: u"piexif" }
exif_dict = {"0th":zeroth_ifd, "Exif":exif_ifd, "GPS":gps_ifd, "1st":first_ifd, "thumbnail":thumbnail} exif_bytes = piexif.dump(exif_dict) im = Image.open("Q:\M\beefeater.jpg") im.thumbnail((2000, 2000), Image.ANTIALIAS) im.save("out.jpg", exif=exif_bytes)