[gnome-games] retro: Save metadata with screenshots



commit d23571260467e24a681de897c4940010ff702947
Author: Mateusz Sieczko <arvamer gmail com>
Date:   Fri Mar 17 11:16:00 2017 +0100

    retro: Save metadata with screenshots
    
    This include game title, platform name, creation time, aspect ratio, and
    GNOME Games as application used to create screenshot.
    
    "Title" filed is included for portability with tools that displays data
    from PNG's tEXt chunk and it combines "Game Title" and "Platform"
    fields. It doesn't have mush sense for screenshots, and separate fields
    are better (think about "Song Title" and "Album" in mp3/ogg metadata)
    but they are non-standard and some tools may not display them (eg.
    Nautilus).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769833

 src/retro/retro-runner.vala |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 8e7b1c6..9d31c34 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -518,7 +518,27 @@ public class Games.RetroRunner : Object, Runner {
 
                var screenshot_path = get_screenshot_path ();
 
-               pixbuf.save (screenshot_path, "png");
+               var now = new GLib.DateTime.now_local ();
+               var creation_time = now.to_string ();
+               var platform = core_source.get_platform ();
+               var platform_name = RetroPlatform.get_platform_name (platform);
+               var title = game_title.get_title ();
+
+               var x_dpi = pixbuf.get_option("x-dpi") ?? "";
+               var y_dpi = pixbuf.get_option("y-dpi") ?? "";
+
+               // See http://www.libpng.org/pub/png/spec/iso/index-object.html#11textinfo
+               // for description of used keys. "Game Title" and "Platform" are
+               // non-standard fields as allowed by PNG specification.
+               pixbuf.save (screenshot_path, "png",
+                            "tEXt::Software", "GNOME Games",
+                            "tEXt::Title", @"Screenshot of $title on $platform_name",
+                            "tEXt::Creation Time", creation_time.to_string (),
+                            "tEXt::Game Title", title,
+                            "tEXt::Platform", platform_name,
+                            "x-dpi", x_dpi,
+                            "y-dpi", y_dpi,
+                            null);
        }
 
        private void load_screenshot () throws Error {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]