[gimp/gimp-2-8] Bug 707239 - Gimp destroys image file when exporting...
- From: Massimo Valentini <mvalentini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Bug 707239 - Gimp destroys image file when exporting...
- Date: Wed, 7 May 2014 16:45:30 +0000 (UTC)
commit d053a751503373f976a26cfd7ff6bf8830228180
Author: Massimo Valentini <mvalentini src gnome org>
Date: Wed May 7 18:42:44 2014 +0200
Bug 707239 - Gimp destroys image file when exporting...
as .tif with jpeg compression
make unsensitive the JPEG radio button when the image
is indexed, similarly to Fax Group 3/4 compression
enabled only for monochrome images
move the file creation/truncation after checking for
invalid requests and return a GError in case of error
(cherry picked from commit 7e80e2e3bc77f17dac3fc0f712970a34215a6814)
Conflicts:
plug-ins/common/file-tiff-save.c
plug-ins/common/file-tiff-save.c | 58 +++++++++++++++++++++++++++----------
1 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/plug-ins/common/file-tiff-save.c b/plug-ins/common/file-tiff-save.c
index 012d71e..20f1111 100644
--- a/plug-ins/common/file-tiff-save.c
+++ b/plug-ins/common/file-tiff-save.c
@@ -113,7 +113,8 @@ static gboolean save_image (const gchar *filename,
GError **error);
static gboolean save_dialog (gboolean has_alpha,
- gboolean is_monochrome);
+ gboolean is_monochrome,
+ gboolean is_indexed);
static void comment_entry_callback (GtkWidget *widget,
gpointer data);
@@ -295,7 +296,8 @@ run (const gchar *name,
/* First acquire information with a dialog */
if (! save_dialog (gimp_drawable_has_alpha (drawable),
- image_is_monochrome (image)))
+ image_is_monochrome (image),
+ gimp_image_base_type (image) == GIMP_INDEXED))
status = GIMP_PDB_CANCEL;
break;
@@ -701,17 +703,6 @@ save_image (const gchar *filename,
tile_height = gimp_tile_height ();
rowsperstrip = tile_height;
- tif = tiff_open (filename, "w", error);
-
- if (! tif)
- {
- if (! error)
- g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
- _("Could not open '%s' for writing: %s"),
- gimp_filename_to_utf8 (filename), g_strerror (errno));
- return FALSE;
- }
-
TIFFSetWarningHandler (tiff_warning);
TIFFSetErrorHandler (tiff_error);
@@ -818,11 +809,37 @@ save_image (const gchar *filename,
{
if (bitspersample != 1 || samplesperpixel != 1)
{
- g_message ("Only monochrome pictures can be compressed with \"CCITT Group 4\" or \"CCITT Group
3\".");
+ const gchar *msg = _("Only monochrome pictures can be compressed "
+ "with \"CCITT Group 4\" or \"CCITT Group 3\".");
+
+ g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, msg);
+
return FALSE;
}
}
+ if (compression == COMPRESSION_JPEG)
+ {
+ if (gimp_image_base_type (image) == GIMP_INDEXED)
+ {
+ g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Indexed pictures cannot be compressed "
+ "with \"JPEG\"."));
+ return FALSE;
+ }
+ }
+
+ tif = tiff_open (filename, "w", error);
+
+ if (! tif)
+ {
+ if (! error)
+ g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+ _("Could not open '%s' for writing: %s"),
+ gimp_filename_to_utf8 (filename), g_strerror (errno));
+ return FALSE;
+ }
+
/* Set TIFF parameters. */
TIFFSetField (tif, TIFFTAG_SUBFILETYPE, 0);
TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, cols);
@@ -1069,7 +1086,8 @@ save_image (const gchar *filename,
static gboolean
save_dialog (gboolean has_alpha,
- gboolean is_monochrome)
+ gboolean is_monochrome,
+ gboolean is_indexed)
{
GtkWidget *dialog;
GtkWidget *vbox;
@@ -1080,6 +1098,7 @@ save_dialog (gboolean has_alpha,
GtkWidget *toggle;
GtkWidget *g3;
GtkWidget *g4;
+ GtkWidget *jpeg;
gboolean run;
dialog = gimp_export_dialog_new (_("TIFF"), PLUG_IN_BINARY, SAVE_PROC);
@@ -1098,7 +1117,7 @@ save_dialog (gboolean has_alpha,
_("_LZW"), COMPRESSION_LZW, NULL,
_("_Pack Bits"), COMPRESSION_PACKBITS, NULL,
_("_Deflate"), COMPRESSION_ADOBE_DEFLATE, NULL,
- _("_JPEG"), COMPRESSION_JPEG, NULL,
+ _("_JPEG"), COMPRESSION_JPEG, &jpeg,
_("CCITT Group _3 fax"), COMPRESSION_CCITTFAX3, &g3,
_("CCITT Group _4 fax"), COMPRESSION_CCITTFAX4, &g4,
@@ -1106,6 +1125,7 @@ save_dialog (gboolean has_alpha,
gtk_widget_set_sensitive (g3, is_monochrome);
gtk_widget_set_sensitive (g4, is_monochrome);
+ gtk_widget_set_sensitive (jpeg, ! is_indexed);
if (! is_monochrome)
{
@@ -1117,6 +1137,12 @@ save_dialog (gboolean has_alpha,
}
}
+ if (is_indexed && tsvals.compression == COMPRESSION_JPEG)
+ {
+ gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (jpeg),
+ COMPRESSION_NONE);
+ }
+
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]