[gimp/gimp-2-10] plug-ins: add option to crop layers to image bounds when exporting TIFF
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] plug-ins: add option to crop layers to image bounds when exporting TIFF
- Date: Thu, 25 Jun 2020 15:35:52 +0000 (UTC)
commit 04d56bf31c7bef1ecc36e75bca805f63ae760980
Author: Ell <ell_se yahoo com>
Date: Thu Jun 25 17:56:41 2020 +0300
plug-ins: add option to crop layers to image bounds when exporting TIFF
In file-tiff, add an option to crop the layers to the image bounds
when exporting individual layers (using GIMP_EXPORT_NEEDS_CROP
added in the previous commit), since TIFF has no concept of global
image bounds otherwise. Cropping is enabled by default.
plug-ins/file-tiff/file-tiff-save.c | 12 ++++++++++++
plug-ins/file-tiff/file-tiff-save.h | 1 +
plug-ins/file-tiff/file-tiff.c | 10 ++++++++--
plug-ins/ui/plug-in-file-tiff.ui | 22 +++++++++++++++++++++-
4 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c
index aebb0f313f..03c3ac6498 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -1271,6 +1271,18 @@ save_dialog (TiffSaveVals *tsvals,
G_CALLBACK (gimp_toggle_button_update),
&tsvals->save_layers);
+ frame = GTK_WIDGET (gtk_builder_get_object (builder, "layers-frame"));
+ g_object_bind_property (toggle, "active",
+ frame, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
+ toggle = GTK_WIDGET (gtk_builder_get_object (builder, "crop-layers"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
+ tsvals->crop_layers);
+ g_signal_connect (toggle, "toggled",
+ G_CALLBACK (gimp_toggle_button_update),
+ &tsvals->crop_layers);
+
gtk_widget_show (dialog);
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
diff --git a/plug-ins/file-tiff/file-tiff-save.h b/plug-ins/file-tiff/file-tiff-save.h
index 24e4f85ba1..b5fb1b3157 100644
--- a/plug-ins/file-tiff/file-tiff-save.h
+++ b/plug-ins/file-tiff/file-tiff-save.h
@@ -34,6 +34,7 @@ typedef struct
gboolean save_thumbnail;
gboolean save_profile;
gboolean save_layers;
+ gboolean crop_layers;
} TiffSaveVals;
diff --git a/plug-ins/file-tiff/file-tiff.c b/plug-ins/file-tiff/file-tiff.c
index 3867807422..61405f12c4 100644
--- a/plug-ins/file-tiff/file-tiff.c
+++ b/plug-ins/file-tiff/file-tiff.c
@@ -88,7 +88,8 @@ static TiffSaveVals tsvals =
FALSE, /* save iptc */
TRUE, /* save thumbnail */
TRUE, /* save profile */
- TRUE /* save layer */
+ TRUE, /* save layers */
+ TRUE /* crop layers */
};
static gchar *image_comment = NULL;
@@ -392,7 +393,12 @@ run (const gchar *name,
GIMP_EXPORT_CAN_HANDLE_ALPHA;
if (tsvals.save_layers)
- capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
+ {
+ capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
+
+ if (tsvals.crop_layers)
+ capabilities |= GIMP_EXPORT_NEEDS_CROP;
+ }
export = gimp_export_image (&image, &drawable, "TIFF", capabilities);
diff --git a/plug-ins/ui/plug-in-file-tiff.ui b/plug-ins/ui/plug-in-file-tiff.ui
index a2c0624724..c6672960e5 100644
--- a/plug-ins/ui/plug-in-file-tiff.ui
+++ b/plug-ins/ui/plug-in-file-tiff.ui
@@ -54,6 +54,26 @@
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GimpFrame" id="layers-frame">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkCheckButton" id="crop-layers">
+ <property name="label" translatable="yes">Cr_op layers to image bounds</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
<child>
<object class="GtkCheckButton" id="save-alpha">
<property name="label" translatable="yes">Save color _values from transparent pixels</property>
@@ -67,7 +87,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]