Difference between revisions of "ImageMetadata"

From The Battle for Wesnoth Wiki
(Initial draft of image metadata guide)
 
(Cleanup formatting)
Line 6: Line 6:
 
'''Exiftool''' is platform-independent, command-line application that has been the primary toolkit applied to Wesnoth images.  More info can be found at https://www.exiftool.org/index.html
 
'''Exiftool''' is platform-independent, command-line application that has been the primary toolkit applied to Wesnoth images.  More info can be found at https://www.exiftool.org/index.html
  
==Basic usage of exiftool==
+
The discussion assumes GIMP (or Krita) is the image editor used, but it is probably equally valid for Adobe PhotoshopOther editors probably have some metadata support, this is a wiki.  
(This is command line
 
to view metadata grouped by tag group
 
''exiftool -g <file>''
 
Note: WEBP must contain "Alpha" in RIFF:WebP_Flags or else the transparent background will be lost when EXIF tags are added. 
 
Exiftool can read but not write this flag (so -all= won't clobber it)GIMP will set this flag, but some "optimizing" scripts or programs can remove it.
 
  
XMP (dc "Dublin Core") tags - Used for PNG because they are most likely to be edited with GIMP
+
===Basic usage of exiftool===
  
exiftool -overwrite_original -all= -Date=<Y:m:d H:M:S> -Rights=<copyright> -Creator=<name (account name)> -Description="<comment>" <target file>
+
To view metadata of an image <file> grouped by tag
 +
<syntaxhighlight> exiftool -g <file> </syntaxhighlight>
 +
'''Note:''' WEBP must contain "Alpha" in RIFF:WebP_Flags or else the transparent background will be lost when EXIF tags are added.  Exiftool can read but not write this flag (so ''-all='' argument won't clobber it).  GIMP will set this flag, but some optimizing scripts or programs can remove it.  Viewing the image metadata with the above command will allow you to check.
  
EXIF - Used for WEBP and JPG, as Exif data seemed more visible in some file managers.
+
To write the needed metadata (Author and Copyright) but remove all the other info injected by image editors (most of which is useful in some context, just not this one), we use ''-all='' to clear the deck.  For small PNG files, thumbnail data can double the file size, and this matters because we have ''a lot'' of these little files.  We can also use ''-overwrite_original'' to prevent a backup file.  Different tag groups have different names for very similar fields, and they often don't match what you see in the image editor dialogs.
 +
* XMP (dc "Dublin Core") tags - Used for PNG because they are most likely to be edited with GIMP (see below).
 +
<syntaxhighlight>exiftool -overwrite_original -all= -Date=<Y:m:d H:M:S> -Rights=<copyright> -Creator=<name (account name)> -Description="<comment>" <target file></syntaxhighlight>
  
We could add both XMP and Exif to all images, but that would make the files larger.
+
* EXIF - Used for WEBP and JPG, as Exif data seemed more visible in some file managers.  We could add both XMP and Exif to all images, but that would make the files larger.
 +
<syntaxhighlight>exiftool -overwrite_original -all= -CreateDate=<Y:m:d H:M:S> -Copyright=<copyright> -Artist=<name (account name)> -UserComment="<comment>" <target file></syntaxhighlight>
  
exiftool -overwrite_original -all= -CreateDate=<Y:m:d H:M:S> -Copyright=<copyright> -Artist=<name (account name)> -UserComment="<comment>" <target file>
+
===Metadata and CI===
  
2.  Metadata and CI
+
====Authorship and Copyright====
  
  A. [Required tags] Authorship and Copyright
+
To satisfy CI, image metadata is checked for a small set of entries.
    i.  PNG - XMP:Creator must exist
+
 
              XMP:Rights must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"
+
For PNG files:
 +
* '''XMP:Creator''' must exist.
 +
 
 +
* '''XMP:Rights''' must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"
 
          
 
          
    ii.  JPEG, WEBP - EXIF:Artist must exist
+
For JPEG, WEBP:
                      EXIF:Copyright must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"
+
* '''EXIF:Artist''' must exist.
 +
 
 +
* '''EXIF:Copyright''' must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"
  
  B. [Optional tags reported in CI]
+
====Optional tags reported in CI====
    i.  {PNG/EXIF/XMP}:{CreateDate,ModifyDate}
+
(This needs to be fixed, both here and CI.)
    ii. {XMP}:{Date}
 
    iii. {PNG/EXIF/XMP}:{UserComment}
 
  
3.  Metadata and GIMP (2.10) - Image->Metadata->Edit Metadata
+
===Metadata and Image Editors===
  A.  PNG - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
+
====GIMP (2.10)====
  B.  WEBP - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
+
Image->Metadata->Edit Metadata
  C.  JPEG - Can read IPTC:By-line or EXIF:Artist (IPTC takes precedence), shown under "Description", exports to XMP and IPTC groups
+
*PNG - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
 +
*WEBP - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
 +
*JPEG - Can read IPTC:By-line or EXIF:Artist (IPTC takes precedence), shown under "Description", exports to XMP and IPTC groups
  
4.  Metadata and Krita (5.1.5) - Layer->Edit Metadata...
+
====Krita (5.1)====
  A.  PNG - Does not always import XMP:Creator or XMP:Rights, but can write to them under "Dublin Core" tab, as well as XMP:Description
+
Layer->Edit Metadata...
  B.  WEBP - Does not seem to import anything, but can write XMP:Creator and XMP:Rights
+
*PNG - Does not always import XMP:Creator or XMP:Rights, but can write to them under "Dublin Core" tab, as well as XMP:Description
  C.  JPEG - Can import EXIF:Artist and EXIF:Copyright, shown under "Dublin Core" as Creator & Rights, exported under IPTC:By-line and IPTC:Copyright Notice
+
*WEBP - Does not seem to import anything, but can write XMP:Creator and XMP:Rights
 +
*JPEG - Can import EXIF:Artist and EXIF:Copyright, shown under "Dublin Core" as Creator & Rights, exported under IPTC:By-line and IPTC:Copyright Notice

Revision as of 01:21, 23 March 2025

Image Metadata

Author and copyright data of Wesnoth images are contained in the image metadata. For most of Wesnoth's project history, image authorship and copyrights were tracked in a separate text document. Such a document can still be generated from the metadata, but is not currently (2025) part of the commit process. There is no expectation that an artist correctly format the metadata, but the individual committing the image to the project files is expected to do so.

A lot of different programs can manipulate metadata, and they all seem to have different ways of doing it. Exiftool is platform-independent, command-line application that has been the primary toolkit applied to Wesnoth images. More info can be found at https://www.exiftool.org/index.html

The discussion assumes GIMP (or Krita) is the image editor used, but it is probably equally valid for Adobe Photoshop. Other editors probably have some metadata support, this is a wiki.

Basic usage of exiftool

To view metadata of an image <file> grouped by tag

 exiftool -g <file>

Note: WEBP must contain "Alpha" in RIFF:WebP_Flags or else the transparent background will be lost when EXIF tags are added. Exiftool can read but not write this flag (so -all= argument won't clobber it). GIMP will set this flag, but some optimizing scripts or programs can remove it. Viewing the image metadata with the above command will allow you to check.

To write the needed metadata (Author and Copyright) but remove all the other info injected by image editors (most of which is useful in some context, just not this one), we use -all= to clear the deck. For small PNG files, thumbnail data can double the file size, and this matters because we have a lot of these little files. We can also use -overwrite_original to prevent a backup file. Different tag groups have different names for very similar fields, and they often don't match what you see in the image editor dialogs.

  • XMP (dc "Dublin Core") tags - Used for PNG because they are most likely to be edited with GIMP (see below).
exiftool -overwrite_original -all= -Date=<Y:m:d H:M:S> -Rights=<copyright> -Creator=<name (account name)> -Description="<comment>" <target file>
  • EXIF - Used for WEBP and JPG, as Exif data seemed more visible in some file managers. We could add both XMP and Exif to all images, but that would make the files larger.
exiftool -overwrite_original -all= -CreateDate=<Y:m:d H:M:S> -Copyright=<copyright> -Artist=<name (account name)> -UserComment="<comment>" <target file>

Metadata and CI

Authorship and Copyright

To satisfy CI, image metadata is checked for a small set of entries.

For PNG files:

  • XMP:Creator must exist.
  • XMP:Rights must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"

For JPEG, WEBP:

  • EXIF:Artist must exist.
  • EXIF:Copyright must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"

Optional tags reported in CI

(This needs to be fixed, both here and CI.)

Metadata and Image Editors

GIMP (2.10)

Image->Metadata->Edit Metadata

  • PNG - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
  • WEBP - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
  • JPEG - Can read IPTC:By-line or EXIF:Artist (IPTC takes precedence), shown under "Description", exports to XMP and IPTC groups

Krita (5.1)

Layer->Edit Metadata...

  • PNG - Does not always import XMP:Creator or XMP:Rights, but can write to them under "Dublin Core" tab, as well as XMP:Description
  • WEBP - Does not seem to import anything, but can write XMP:Creator and XMP:Rights
  • JPEG - Can import EXIF:Artist and EXIF:Copyright, shown under "Dublin Core" as Creator & Rights, exported under IPTC:By-line and IPTC:Copyright Notice