[gimp/metadata-wip-rebased: 9/9] plug-ins: add metadata support to file-psd-load and file-psd-save



commit 45786b100eab6b35daa3abf2ec06cf981a8940bd
Author: Michael Natterer <mitch gimp org>
Date:   Tue Oct 22 22:49:16 2013 +0200

    plug-ins: add metadata support to file-psd-load and file-psd-save

 plug-ins/file-psd/psd-save.c |   27 +++++++++++++++++++++++++++
 plug-ins/file-psd/psd.c      |   29 ++++++++++++++++++++++++++---
 2 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index 9b30ce1..ce7ae57 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -293,6 +293,33 @@ run (const gchar      *name,
 
       if (save_image (param[3].data.d_string, image_id, &error))
         {
+          GimpMetadata *metadata;
+
+          metadata = gimp_image_metadata_save_prepare (image_id,
+                                                       "image/x-psd");
+
+          if (metadata)
+            {
+              GFile                 *file;
+              GimpMetadataSaveFlags  flags = 0;
+
+              gimp_metadata_set_bits_per_sample (metadata, 8);
+
+              if (TRUE) flags |= GIMP_METADATA_SAVE_EXIF;
+              if (TRUE) flags |= GIMP_METADATA_SAVE_XMP;
+              if (TRUE) flags |= GIMP_METADATA_SAVE_IPTC;
+              if (TRUE) flags |= GIMP_METADATA_SAVE_THUMBNAIL;
+
+              file = g_file_new_for_path (param[3].data.d_string);
+              gimp_image_metadata_save_finish (image_id,
+                                               "image/x-psd",
+                                               metadata, file, flags,
+                                               NULL);
+              g_object_unref (file);
+
+              g_object_unref (metadata);
+            }
+
           values[0].data.d_status = GIMP_PDB_SUCCESS;
         }
       else
diff --git a/plug-ins/file-psd/psd.c b/plug-ins/file-psd/psd.c
index 97668e1..b2bfc3e 100644
--- a/plug-ins/file-psd/psd.c
+++ b/plug-ins/file-psd/psd.c
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
 
 #include "psd.h"
 #include "psd-load.h"
@@ -34,6 +35,7 @@
 
 #include "libgimp/stdplugins-intl.h"
 
+
 /*  Local function prototypes  */
 
 static void  query (void);
@@ -168,6 +170,7 @@ run (const gchar      *name,
      GimpParam       **return_vals)
 {
   static GimpParam  values[4];
+  GimpRunMode       run_mode;
   GimpPDBStatusType status = GIMP_PDB_SUCCESS;
   gint32            image_ID;
   GError           *error  = NULL;
@@ -176,6 +179,8 @@ run (const gchar      *name,
   GimpExportReturn  export = GIMP_EXPORT_CANCEL;
 #endif /* PSD_SAVE */
 
+  run_mode = param[0].data.d_int32;
+
   INIT_I18N ();
 
   *nreturn_vals = 1;
@@ -187,10 +192,31 @@ run (const gchar      *name,
   /* File load */
   if (strcmp (name, LOAD_PROC) == 0)
     {
+      gboolean interactive;
+
+      switch (run_mode)
+        {
+        case GIMP_RUN_INTERACTIVE:
+        case GIMP_RUN_WITH_LAST_VALS:
+          gimp_ui_init (PLUG_IN_BINARY, FALSE);
+          interactive = TRUE;
+          break;
+        default:
+          interactive = FALSE;
+          break;
+        }
+
       image_ID = load_image (param[1].data.d_string, &error);
 
       if (image_ID != -1)
         {
+          GFile *file = g_file_new_for_path (param[1].data.d_string);
+
+          gimp_image_metadata_load (image_ID, "image/x-psd", file,
+                                    interactive);
+
+          g_object_unref (file);
+
           *nreturn_vals = 2;
           values[1].type         = GIMP_PDB_IMAGE;
           values[1].data.d_image = image_ID;
@@ -237,9 +263,6 @@ run (const gchar      *name,
   /* File save */
   else if (strcmp (name, SAVE_PROC) == 0)
     {
-      GimpRunMode run_mode;
-
-      run_mode = param[0].data.d_int32;
       image_ID = param[1].data.d_int32;
       drawable_ID = param[2].data.d_int32;
 


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