[gimp/gimp-2-8] Bug 705457 - Export doesn't handle a single top-level layer group



commit cdb0b5816e13843c811abf35635ff4b334f78b14
Author: Michael Natterer <mitch gimp org>
Date:   Sun Nov 10 01:54:45 2013 +0100

    Bug 705457 - Export doesn't handle a single top-level layer group
    
    Add special export code for single top-level layers groups, other
    cases should be mostly (not perfectly) handled by the export code
    for layered images. Also, show the legacy export dialog when the
    envorinment variable GIMP_INTERACTIVE_EXPORT is set, so export
    changes can actually be tested and verified again.
    
    (cherry picked from commit 8c79a070bb28416752d76c4f8505119871819bfb)

 libgimp/gimpexport.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c
index 7d84811..3433c4a 100644
--- a/libgimp/gimpexport.c
+++ b/libgimp/gimpexport.c
@@ -715,7 +715,7 @@ gimp_export_image (gint32                 *image_ID,
   if (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS)
     capabilities |= GIMP_EXPORT_CAN_HANDLE_ALPHA;
 
-  if (FALSE /* format_name */)
+  if (format_name && g_getenv ("GIMP_INTERACTIVE_EXPORT"))
     interactive = TRUE;
 
   /* ask for confirmation if the user is not saving a layer (see bug #51114) */
@@ -786,12 +786,16 @@ gimp_export_image (gint32                 *image_ID,
         }
     }
 
-  g_free (layers);
-
   if (! added_flatten)
     {
+      gint32  n_children;
+      gint32 *children;
+
+      children = gimp_item_get_children (layers[0], &n_children);
+
       /* check if layer size != canvas size, opacity != 100%, or offsets != 0 */
       if (n_layers == 1                     &&
+          ! children                        &&
           gimp_item_is_layer (*drawable_ID) &&
           ! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
         {
@@ -842,6 +846,21 @@ gimp_export_image (gint32                 *image_ID,
                                            &export_action_merge_or_flatten);
             }
         }
+      /* check for a single toplevel layer group */
+      else if (children)
+        {
+          if (! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
+            {
+              if (capabilities & GIMP_EXPORT_NEEDS_ALPHA)
+                actions = g_slist_prepend (actions,
+                                           &export_action_merge);
+              else
+                actions = g_slist_prepend (actions,
+                                           &export_action_merge_or_flatten);
+            }
+        }
+
+      g_free (children);
 
       /* check layer masks */
       if (has_layer_masks &&
@@ -849,6 +868,8 @@ gimp_export_image (gint32                 *image_ID,
         actions = g_slist_prepend (actions, &export_action_apply_masks);
     }
 
+  g_free (layers);
+
   /* check the image type */
   type = gimp_image_base_type (*image_ID);
   switch (type)


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