Commit 7f39be86 authored by Ell's avatar Ell

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.
parent 4c8ee413
Pipeline #191315 passed with stages
in 28 minutes and 42 seconds
......@@ -1286,7 +1286,7 @@ save_dialog (GimpImage *image,
else
{
/* If single-layer TIFF, set the toggle insensitive and show it as
* unchecked though I don't actually change the tsvals value to
* unchecked though I don't actually change the config value to
* keep storing previously chosen value.
*/
button = gtk_check_button_new_with_mnemonic (_("Save layers"));
......@@ -1296,6 +1296,33 @@ save_dialog (GimpImage *image,
gtk_grid_attach (GTK_GRID (grid), button, 0, row++, 2, 1);
frame = gimp_frame_new (NULL);
gtk_grid_attach (GTK_GRID (grid), frame, 0, row++, 2, 1);
gtk_widget_show (frame);
if (is_multi_layer)
{
g_object_bind_property (config, "save-layers",
frame, "sensitive",
G_BINDING_SYNC_CREATE);
button = gimp_prop_check_button_new (config, "crop-layers",
_("Crop layers to image bounds"));
gtk_container_add (GTK_CONTAINER (frame), button);
}
else
{
/* If single-layer TIFF, set the layers frame insensitive and
* show its toggles as unchecked though I don't actually change
* the config value to keep storing previously chosen values.
*/
gtk_widget_set_sensitive (frame, FALSE);
button = gtk_check_button_new_with_mnemonic (_("Crop layers"));
gtk_container_add (GTK_CONTAINER (frame), button);
gtk_widget_show (button);
}
if (has_alpha && ! is_indexed)
{
button = gimp_prop_check_button_new (config, "save-transparent-pixels",
......
......@@ -223,6 +223,12 @@ tiff_create_procedure (GimpPlugIn *plug_in,
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_BOOLEAN (procedure, "crop-layers",
"Crop Layers",
"Crop Layers",
TRUE,
G_PARAM_READWRITE);
GIMP_PROC_AUX_ARG_BOOLEAN (procedure, "save-exif",
"Save Exif",
"Save Exif",
......@@ -373,10 +379,12 @@ tiff_save (GimpProcedure *procedure,
GimpExportCapabilities capabilities;
GimpCompression compression;
gboolean save_layers;
gboolean crop_layers;
g_object_get (config,
"compression", &compression,
"save-layers", &save_layers,
"crop-layers", &crop_layers,
NULL);
if (compression == GIMP_COMPRESSION_CCITTFAX3 ||
......@@ -396,7 +404,12 @@ tiff_save (GimpProcedure *procedure,
}
if (save_layers && image_is_multi_layer (image))
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
{
capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYERS;
if (crop_layers)
capabilities |= GIMP_EXPORT_NEEDS_CROP;
}
export = gimp_export_image (&image, &n_drawables, &drawables, "TIFF",
capabilities);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment