LeoHsiao1 / pyexiv2

Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.
GNU General Public License v3.0
201 stars 39 forks source link

clear_exif() / clear_iptc() / clear_xmp() not clearing Comment field #37

Closed dgtlmoon closed 3 years ago

dgtlmoon commented 3 years ago

ab95627d37e9f9baecea24ee52b6377e

        exiv_image = pyexiv2.Image(filepath)
        exiv_image.clear_exif()
        exiv_image.clear_iptc()
        exiv_image.clear_xmp()

then I look at the file with exiftool

ExifTool Version Number         : 11.16
File Name                       : ab95627d37e9f9baecea24ee52b6377e.jpg
Directory                       : /var/www/tshirtslayer/web/files-tshirt/styles/shirtview/public/user-11635
File Size                       : 35 kB
File Modification Date/Time     : 2020:12:25 21:13:06+00:00
File Access Date/Time           : 2016:01:15 06:02:14+00:00
File Inode Change Date/Time     : 2020:12:25 21:13:06+00:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 96
Y Resolution                    : 96
Comment                         : CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 80.
Image Width                     : 856
Image Height                    : 482
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 856x482
Megapixels                      : 0.413

I was hoping that

Comment : CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 80.

would be gone

I'm also unable to override that with

            exiv_image.modify_exif({'Exif.Image.DocumentName': description,
                                    'Exif.Image.ImageDescription': description,
                                    'Exif.Photo.UserComment': description,
                                    'Exif.Image.Copyright' : "Copyright Creative Commons 3.0",
                                    'Exif.Image.DateTime': exif_date,
                                    'Exif.Image.DateTimeOriginal' : exif_date,
                                    'Exif.Photo.DateTimeDigitized' : exif_date,
                                    }
                                   )

ideas? file attached

dgtlmoon commented 3 years ago

after

        exiv_image.clear_exif()
        exiv_image.clear_iptc()
        exiv_image.clear_xmp()

exiftool with -v gives..

  ExifToolVersion = 11.16
  FileName = ab95627d37e9f9baecea24ee52b6377e.jpg
  FileSize = 35564
  FileModifyDate = 1608930786
  FileAccessDate = 1452837734
  FileInodeChangeDate = 1608930786
  FilePermissions = 33204
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | ResolutionUnit = 1
  | XResolution = 96
  | YResolution = 96
  | ThumbnailWidth = 0
  | ThumbnailHeight = 0
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG COM (58 bytes):
  Comment = CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 80.
JPEG SOF0 (15 bytes):
  ImageWidth = 856
  ImageHeight = 482
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 3
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG SOS
LeoHsiao1 commented 3 years ago

An interesting picture. However, Github will automatically delete the metadata of your uploaded images, which is more thorough than my pyexiv2. Please send the picture to my mailbox and I will test it.

dgtlmoon commented 3 years ago

@LeoHsiao1 You should try to look at the data before making sweeping assumptions..

$ curl -q https://user-images.githubusercontent.com/275001/103142222-071f5c80-4700-11eb-9425-55cfc6d440e0.jpg|exiftool -|grep Comment
Comment                         : CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 80.

I see it directly from github..

dgtlmoon commented 3 years ago

Can it be that this comment field is not part of the EXIF dataset?

LeoHsiao1 commented 3 years ago

I parse your image with exiv2, and the metadata displayed is empty:

C:\Users\Leo>exiv2-0.27.2-2017msvc64\bin\exiv2.exe print D:\1.jpg
File name       : D:\1.jpg
File size       : 35564 Bytes
MIME type       : image/jpeg
Image size      : 856 x 482
D:\1.jpg: No Exif data found in the file

Then I parsed it with exifTool and showed that comment belonged to the JPEG tag.

$ ./exiftool ../1.jpg -v
  ExifToolVersion = 12.13
  FileName = 1.jpg
  Directory = ..
  FileSize = 35564
  FileModifyDate = 1608978733
  FileAccessDate = 1608979346
  FileInodeChangeDate = 1608979348
  FilePermissions = 33279
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | ResolutionUnit = 1
  | XResolution = 96
  | YResolution = 96
  | ThumbnailWidth = 0
  | ThumbnailHeight = 0
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG COM (58 bytes):                    # <--- here
  Comment = CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 80.
JPEG SOF0 (15 bytes):
  ImageWidth = 856
  ImageHeight = 482
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 3
  YCbCrSubSampling = 2 2
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG SOS
dgtlmoon commented 3 years ago

https://stackoverflow.com/questions/17447201/how-do-text-comments-in-jpg-files-work

dgtlmoon commented 3 years ago

So what todo? I guess this is not part of your library?

LeoHsiao1 commented 3 years ago

In short, JPEG COM is part of the JPEG image structure and is not a generic metadata standard.

dgtlmoon commented 3 years ago

OK, yeah I think probably good enough..

github-actions[bot] commented 3 years ago

This issue has been automatically closed because there has been no activity for a month.