Option to keep specific metadata?
c6y opened this issue · 2 comments
c6y commented
I'd like to keep keywords and some IPTC and EXIF metadata. Is this possible?
lvandeve commented
You can keep metadata with the --keepchunks=<chunknames...> flag. For this you need to know the names of the PNG chunks the metadata you wish to keep is stored in in your file (see http://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_PNG_files)
For example if it's in iTXt, tEXt and/or zTXt chunks, you can try adding the flag
--keepchunks=iTXt, tEXt,zTXt
Does this work?
c6y commented
Thanks Lode! Keeping the uTXt chunk works:
tmpfile=$(mktemp)
zopflipng -m -y --keepchunks=iTXt $1 $tmpfile
mv $tmpfile $1
In this case I just need to keep the Create Date
metadata. The rest of the metadata could be removed. Is this possible?
Preserved metadata after compression — output via exiftool:
======== ./myfile.png
ExifTool Version Number : 10.47
File Name : myfile.png
Directory : .
File Size : 2.5 kB
File Modification Date/Time : 2017:03:22 15:22:59-07:00
File Access Date/Time : 2017:03:22 15:23:27-07:00
File Inode Change Date/Time : 2017:03:22 15:22:59-07:00
File Permissions : rw-------
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 54
Image Height : 43
Bit Depth : 4
Color Type : Palette
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
XMP Toolkit : Adobe XMP Core 5.6-c014 79.156797, 2014/08/20-09:53:02
Creator Tool : Adobe Photoshop CC 2014 (Macintosh)
Create Date : 2014:10:28 23:35:57-07:00
Metadata Date : 2015:05:15 20:22:12-07:00
Modify Date : 2015:05:15 20:22:12-07:00
Format : image/png
Instance ID : xmp.iid:28698FBAF36411E4B1AFCA9E1202FD7D
Document ID : xmp.did:28698FBBF36411E4B1AFCA9E1202FD7D
Original Document ID : xmp.did:80d5d65d-f02a-404c-9e88-f04fc2f1f2f6
History Action : created, saved, saved
History Instance ID : xmp.iid:80d5d65d-f02a-404c-9e88-f04fc2f1f2f6, xmp.iid:f7eb5048-aee4-428c-b37b-e2290465a66f, xmp.iid:fbc28a4e-df67-4994-9e9b-55a1e8f1d31b
History When : 2014:10:28 23:35:57-07:00, 2014:10:28 23:36:46-07:00, 2015:05:15 13:13:01-07:00
History Software Agent : Adobe Photoshop CC 2014 (Macintosh), Adobe Photoshop CC 2014 (Macintosh), Adobe Photoshop CC 2014 (Macintosh)
History Changed : /, /
Derived From Instance ID : xmp.iid:fbc28a4e-df67-4994-9e9b-55a1e8f1d31b
Derived From Document ID : adobe:docid:photoshop:2e0c3f68-3bcd-1178-8e18-e53a97ba8791
Document Ancestors : xmp.did:089A9EDF0920681183BA8760C1477831, xmp.did:80d5d65d-f02a-404c-9e88-f04fc2f1f2f6
Palette : (Binary data 45 bytes, use -b option to extract)
Transparency : (Binary data 15 bytes, use -b option to extract)
Image Size : 54x43
Megapixels : 0.002