Difference between revisions of "ImageMetadata"

From The Battle for Wesnoth Wiki
(Initial draft of image metadata guide)
 
(corrections and examples)
 
(4 intermediate revisions by the same user not shown)
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
 +
    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 is supposed to read but not write this flag (so ''-all='' argument shouldn't clobber it, but sometimes it does).  GIMP will set this flag, but it can get removed by further processing.  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).
 +
    exiftool -overwrite_original -all= -Date="<Y:m:d H:M:S>" -Rights="<copyright>" -Creator="<name (account name)>" -Description="<comment>" <target file>
  
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.
 +
    exiftool -overwrite_original -all= -CreateDate="<Y:m:d H:M:S>" -Copyright="<copyright>" -Artist="<name (account name)>" -UserComment="<comment>" <target file>
  
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"
 
       
 
    ii.  JPEG, WEBP - EXIF:Artist must exist
 
                      EXIF:Copyright must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"
 
  
  B. [Optional tags reported in CI]
+
For PNG files:
    i.  {PNG/EXIF/XMP}:{CreateDate,ModifyDate}
+
* '''XMP:Creator''' must exist.
    ii. {XMP}:{Date}
 
    iii. {PNG/EXIF/XMP}:{UserComment}
 
  
3.  Metadata and GIMP (2.10) - Image->Metadata->Edit Metadata
+
* '''XMP:Rights''' must contain "GNU GPL v2+", "CC BY-SA 4.0", or "CC0"
  A.  PNG - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
 
  B.  WEBP - Can read/write XMP:Creator, XMP:Rights, and XMP:Description under the "Description" tab
 
  C.  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...
+
For JPEG, WEBP:
  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
+
* '''EXIF:Artist''' must exist.
  B.  WEBP - Does not seem to import anything, but can write XMP:Creator and XMP:Rights
+
 
  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
+
* '''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
 +
 
 +
 
 +
===Examples===
 +
A sprite (PNG) with the needed XMP tags is shown below.
 +
 
 +
https://forums.wesnoth.org/download/file.php?id=99456&type=.png
 +
 
 +
Examples of WebP showing the Alpha flag issue can be found at this forum post:
 +
 +
https://forums.wesnoth.org/viewtopic.php?p=694451#p694451
 +
 
 +
== See also ==
 +
* [[Create]]
 +
* [[Maintenance_tools]]
 +
 
 +
[[Category:Development]]

Latest revision as of 12:16, 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 is supposed to read but not write this flag (so -all= argument shouldn't clobber it, but sometimes it does). GIMP will set this flag, but it can get removed by further processing. 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


Examples

A sprite (PNG) with the needed XMP tags is shown below.

file.php?id=99456&type=.png

Examples of WebP showing the Alpha flag issue can be found at this forum post:

https://forums.wesnoth.org/viewtopic.php?p=694451#p694451

See also

This page was last edited on 23 March 2025, at 12:16.