Commit 415a61cd authored by Paolo Bacchilega's avatar Paolo Bacchilega

added ability to specify the file type options when saving images

parent 8495ffb1
......@@ -223,17 +223,40 @@ AC_MSG_CHECKING(JPEG Support)
AC_ARG_ENABLE([jpeg],
[AS_HELP_STRING([--disable-jpeg],[do not compile code that uses the libjpeg library])],,
[enable_jpeg=yes])
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
[enable_jpeg=yes],
[enable_jpeg=no])
if test "x$enable_jpeg" = "xyes"; then
AC_DEFINE(HAVE_LIBJPEG, 1, [Define to 1 if libjpeg support is included])
JPEG_LIBS='-ljpeg -lm -lz'
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
[enable_jpeg=yes],
[enable_jpeg=no])
if test "x$enable_jpeg" = "xyes"; then
AC_DEFINE(HAVE_LIBJPEG, 1, [Define to 1 if libjpeg support is included])
JPEG_LIBS='-ljpeg -lm -lz'
fi
fi
AC_SUBST(JPEG_LIBS)
AM_CONDITIONAL(ENABLE_JPEG_TOOLS, test "x$enable_jpeg" = xyes)
AC_MSG_RESULT($enable_jpeg)
dnl ===========================================================================
AC_MSG_CHECKING(TIFF Support)
AC_ARG_ENABLE([tiff],
[AC_HELP_STRING([--disable-tiff],[do not compile code that uses the libtiff library])],,
[enable_tiff=yes])
if test x$enable_tiff = xyes ; then
AC_CHECK_LIB(tiff, TIFFWriteScanline,
[AC_CHECK_HEADER(tiffio.h,
[enable_tiff=yes],
[enable_tiff=no])],
[enable_tiff=no])
if test "x$enable_tiff" = "xyes"; then
AC_DEFINE(HAVE_LIBTIFF, 1, [Define to 1 if libtiff support is included])
TIFF_LIBS='-ltiff -lm -lz'
fi
fi
AC_SUBST(TIFF_LIBS)
AC_MSG_RESULT($enable_tiff)
dnl ===========================================================================
AC_CONFIG_FILES([
......@@ -272,12 +295,16 @@ extensions/image_rotation/Makefile
extensions/image_viewer/Makefile
extensions/image_viewer/data/Makefile
extensions/image_viewer/data/ui/Makefile
extensions/jpeg_utils/Makefile
extensions/list_tools/Makefile
extensions/list_tools/data/Makefile
extensions/list_tools/data/ui/Makefile
extensions/photo_importer/Makefile
extensions/photo_importer/data/Makefile
extensions/photo_importer/data/ui/Makefile
extensions/pixbuf_savers/Makefile
extensions/pixbuf_savers/data/Makefile
extensions/pixbuf_savers/data/ui/Makefile
extensions/red_eye_removal/Makefile
extensions/red_eye_removal/data/Makefile
extensions/red_eye_removal/data/ui/Makefile
......@@ -313,5 +340,6 @@ Configuration:
Build tests : $ENABLE_TEST_SUITE
Exiv2 support : ${enable_exiv2}
JPEG tools : ${enable_jpeg}
TIFF tools : ${enable_tiff}
Clutter support : ${enable_clutter}
"
......@@ -492,116 +492,6 @@
</locale>
</schema>
<!-- JPEG Saver -->
<schema>
<key>/schemas/apps/gthumb/dialogs/jpeg_saver/quality</key>
<applyto>/apps/gthumb/dialogs/jpeg_saver/quality</applyto>
<owner>gthumb</owner>
<type>int</type>
<default>85</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/dialogs/jpeg_saver/smoothing</key>
<applyto>/apps/gthumb/dialogs/jpeg_saver/smoothing</applyto>
<owner>gthumb</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/dialogs/jpeg_saver/optimize</key>
<applyto>/apps/gthumb/dialogs/jpeg_saver/optimize</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/dialogs/jpeg_saver/pregressive</key>
<applyto>/apps/gthumb/dialogs/jpeg_saver/pregressive</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>false</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<!-- TGA Saver -->
<schema>
<key>/schemas/apps/gthumb/dialogs/tga_saver/rle_compression</key>
<applyto>/apps/gthumb/dialogs/tga_saver/rle_compression</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<!-- TIFF Saver -->
<schema>
<key>/schemas/apps/gthumb/dialogs/tiff_saver/compression</key>
<applyto>/apps/gthumb/dialogs/tiff_saver/compression</applyto>
<owner>gthumb</owner>
<type>string</type>
<default>deflate</default>
<locale name="C">
<short></short>
<long> Possible values are: none, deflate, jpeg.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/dialogs/tiff_saver/horizontal_resolution</key>
<applyto>/apps/gthumb/dialogs/tiff_saver/horizontal_resolution</applyto>
<owner>gthumb</owner>
<type>int</type>
<default>72</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/dialogs/tiff_saver/vertical_resolution</key>
<applyto>/apps/gthumb/dialogs/tiff_saver/vertical_resolution</applyto>
<owner>gthumb</owner>
<type>int</type>
<default>72</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<!-- Messages -->
<schema>
......
......@@ -185,8 +185,8 @@
<child>
<object class="GtkFileChooserButton" id="startup_dir_filechooserbutton">
<property name="visible">True</property>
<property name="action">select-folder</property>
<property name="local_only">False</property>
<property name="action">select-folder</property>
<property name="title" translatable="yes">Choose startup folder</property>
</object>
<packing>
......
......@@ -7,8 +7,10 @@ SUBDIRS = \
file_viewer \
image_rotation \
image_viewer \
jpeg_utils \
list_tools \
photo_importer \
pixbuf_savers \
red_eye_removal \
rename_series \
resize_images \
......
......@@ -669,10 +669,10 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
extern "C"
gboolean
exiv2_supports_writes (GthFileData *file_data)
exiv2_supports_writes (const char *mime_type)
{
return (g_content_type_equals (gth_file_data_get_mime_type (file_data), "image/jpeg") ||
g_content_type_equals (gth_file_data_get_mime_type (file_data), "image/png"));
return (g_content_type_equals (mime_type, "image/jpeg") ||
g_content_type_equals (mime_type, "image/png"));
}
......@@ -680,7 +680,7 @@ extern "C"
gboolean
exiv2_write_metadata (SavePixbufData *data)
{
if (exiv2_supports_writes (data->file_data)) {
if (exiv2_supports_writes (data->mime_type)) {
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
g_assert (image.get() != 0);
......
......@@ -44,7 +44,7 @@ gboolean exiv2_write_metadata_to_buffer (void **buffer,
GFileInfo *info,
GdkPixbuf *pixbuf, /* optional */
GError **error);
gboolean exiv2_supports_writes (GthFileData *file_data);
gboolean exiv2_supports_writes (const char *mime_type);
G_END_DECLS
......
......@@ -87,7 +87,7 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
GError *error = NULL;
GObject *metadata;
if (! exiv2_supports_writes (file_data))
if (! exiv2_supports_writes (gth_file_data_get_mime_type (file_data)))
return;
if (! g_load_file_in_buffer (file_data->file, &buffer, &size, &error))
......
extensiondir = $(libdir)/gthumb-2.0/extensions
extension_LTLIBRARIES = libimage_rotation.la
if ENABLE_JPEG_TOOLS
JPEG_FILES = \
jmemorydest.c \
jmemorysrc.c \
jpegtran.c \
jpegtran.h \
transupp.c \
transupp.h
else
JPEG_FILES =
endif
libimage_rotation_la_SOURCES = \
$(JPEG_FILES) \
actions.c \
......
......@@ -8,3 +8,4 @@ Version=1.0
[Loader]
Type=module
File=%LIBRARY%
Requires=jpeg_utils
......@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <extensions/jpeg_utils/jpegtran.h>
#include "rotation-utils.h"
......@@ -303,7 +304,6 @@ file_buffer_ready_cb (void *buffer,
GInputStream *istream;
GdkPixbuf *original_pixbuf;
GdkPixbuf *transformed_pixbuf;
char *pixbuf_type;
istream = g_memory_input_stream_new_from_data (buffer, count, NULL);
original_pixbuf = gdk_pixbuf_new_from_stream (istream, tdata->cancellable, &error);
......@@ -314,16 +314,12 @@ file_buffer_ready_cb (void *buffer,
}
transformed_pixbuf = _gdk_pixbuf_transform (original_pixbuf, tdata->transform);
pixbuf_type = get_pixbuf_type_from_mime_type (gth_file_data_get_mime_type (tdata->file_data));
_gdk_pixbuf_save_async (transformed_pixbuf,
tdata->file_data,
pixbuf_type,
NULL,
NULL,
gth_file_data_get_mime_type (tdata->file_data),
pixbuf_saved_cb,
tdata);
g_free (pixbuf_type);
g_object_unref (transformed_pixbuf);
g_object_unref (original_pixbuf);
g_object_unref (istream);
......
......@@ -26,7 +26,8 @@
#include <config.h>
#include <gtk/gtk.h>
#include <gthumb.h>
#include "jpegtran.h"
#include <extensions/jpeg_utils/jpegtran.h>
typedef void (*TrimResponseFunc) (JpegMcuAction action, gpointer user_data);
......
......@@ -736,7 +736,6 @@ _gth_image_viewer_page_real_save (GthViewerPage *base,
{
GthImageViewerPage *self;
SaveData *data;
char *pixbuf_type;
GthFileData *current_file;
self = (GthImageViewerPage *) base;
......@@ -748,7 +747,6 @@ _gth_image_viewer_page_real_save (GthViewerPage *base,
if (mime_type == NULL)
mime_type = gth_file_data_get_mime_type (self->priv->file_data);
pixbuf_type = get_pixbuf_type_from_mime_type (mime_type);
current_file = gth_browser_get_current_file (self->priv->browser);
data->original_file = gth_file_data_dup (current_file);
......@@ -758,13 +756,9 @@ _gth_image_viewer_page_real_save (GthViewerPage *base,
_gdk_pixbuf_save_async (gth_image_viewer_get_current_pixbuf (GTH_IMAGE_VIEWER (self->priv->viewer)),
current_file,
pixbuf_type,
NULL,
NULL,
mime_type,
image_saved_cb,
data);
g_free (pixbuf_type);
}
......
extensiondir = $(libdir)/gthumb-2.0/extensions
extension_LTLIBRARIES = libjpeg_utils.la
if ENABLE_JPEG_TOOLS
libjpeg_utils_la_SOURCES = \
jmemorydest.c \
jmemorydest.h \
jmemorysrc.c \
jmemorysrc.h \
jpegtran.c \
jpegtran.h \
main.c \
transupp.c \
transupp.h
else
libjpeg_utils_la_SOURCES =
endif
libjpeg_utils_la_CFLAGS = $(GTHUMB_CFLAGS) $(DISABLE_DEPRECATED) $(WARNINGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libjpeg_utils_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
libjpeg_utils_la_LIBADD = $(GTHUMB_LIBS) $(JPEG_LIBS)
libjpeg_utils_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
extensioninidir = $(extensiondir)
extensionini_in_files = jpeg_utils.extension.in.in
extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
sed -e "s|%LIBRARY%|`. ./$(extension_LTLIBRARIES) && echo $$dlname`|" \
$< > $@
%.extension: %.extension.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
EXTRA_DIST = $(extensionini_in_files)
DISTCLEANFILES = $(extensionini_DATA)
-include $(top_srcdir)/git.mk
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2001-2009 The Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#ifndef JMEMORYDEST_H
#define JMEMORYDEST_H
#include <jpeglib.h>
#include <glib.h>
void _jpeg_memory_dest (j_compress_ptr cinfo,
void **out_buffer,
gsize *out_buffer_size);
#endif /* JMEMORYDEST_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2001-2009 The Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#ifndef JMEMORYSRC_H
#define JMEMORYSRC_H
#include <jpeglib.h>
#include <glib.h>
void _jpeg_memory_src (j_decompress_ptr cinfo,
void *in_buffer,
gsize in_buffer_size);
#endif /* JMEMORYSRC_H */
[Extension]
Mandatory=true
[Loader]
Type=module
File=%LIBRARY%
......@@ -49,6 +49,8 @@
#include <glib.h>
#include <gthumb.h>
#include "transupp.h"
#include "jmemorydest.h"
#include "jmemorysrc.h"
#include "jpegtran.h"
......@@ -257,14 +259,6 @@ jpegtran_internal (struct jpeg_decompress_struct *srcinfo,
}
void _jpeg_memory_src (j_decompress_ptr cinfo,
void *in_buffer,
gsize in_buffer_size);
void _jpeg_memory_dest (j_compress_ptr cinfo,
void **out_buffer,
gsize *out_buffer_size);
gboolean
jpegtran (void *in_buffer,
gsize in_buffer_size,
......
......@@ -25,6 +25,7 @@
#include <config.h>
#include <glib.h>
#include <gthumb.h>
#include "transupp.h"
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <gtk/gtk.h>
G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
}
G_MODULE_EXPORT void
gthumb_extension_deactivate (void)
{
}
G_MODULE_EXPORT gboolean
gthumb_extension_is_configurable (void)
{
return FALSE;
}
G_MODULE_EXPORT void
gthumb_extension_configure (GtkWindow *parent)
{
}
......@@ -238,13 +238,13 @@ gth_script_editor_dialog_get_script (GthScriptEditorDialog *self,
NULL);
if (g_strcmp0 (gth_script_get_display_name (script), "") == 0) {
*error = g_error_new (GTHUMB_ERROR, 0, _("No name specified"));
*error = g_error_new (GTH_ERROR, 0, _("No name specified"));
g_object_unref (script);
return NULL;
}
if (g_strcmp0 (gth_script_get_command (script), "") == 0) {
*error = g_error_new (GTHUMB_ERROR, 0, _("No command specified"));
*error = g_error_new (GTH_ERROR, 0, _("No command specified"));
g_object_unref (script);
return NULL;
}
......
SUBDIRS = data
extensiondir = $(libdir)/gthumb-2.0/extensions
extension_LTLIBRARIES = libpixbuf_savers.la
ENUM_TYPES = \
enum-types.h \
enum-types.c
HEADER_FILES = \
preferences.h
enum-types.h: $(HEADER_FILES) $(GLIB_MKENUMS)
$(GLIB_MKENUMS) \
--fhead "#ifndef ENUM_TYPES_H\n#define ENUM_TYPES_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
--fprod "/* enumerations from \"@filename@\" */\n" \
--vhead "GType @enum_name@_get_type (void);\n#define GTH_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
--ftail "G_END_DECLS\n\n#endif /* ENUM_TYPES_H */" \
$^> xgen-$(@F) \
&& (cmp -s xgen-$(@F) enum-types.h || cp xgen-$(@F) enum-types.h ) \
&& rm -f xgen-$(@F)
enum-types.c: $(HEADER_FILES) enum-types.h
$(GLIB_MKENUMS) \
--fhead "#include <glib-object.h>\n" \
--fprod "\n/* enumerations from \"@filename@\" */\n#include \"@filename@\"" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
--vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
$^> xgen-$(@F) \
&& (cmp -s xgen-$(@F) enum-types.c || cp xgen-$(@F) enum-types.c ) \
&& rm -f xgen-$(@F)
libpixbuf_savers_la_SOURCES = \
$(ENUM_TYPES) \
$(HEADER_FILES) \
gth-jpeg-saver.c \
gth-jpeg-saver.h \
gth-png-saver.c \
gth-png-saver.h \
gth-tga-saver.c \
gth-tga-saver.h \
gth-tiff-saver.c \
gth-tiff-saver.h \
main.c \
preferences.c
libpixbuf_savers_la_CFLAGS = $(GTHUMB_CFLAGS) $(CLUTTER_CFLAGS) $(DISABLE_DEPRECATED) $(WARNINGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libpixbuf_savers_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
libpixbuf_savers_la_LIBADD = $(GTHUMB_LIBS) $(TIFF_LIBS)
libpixbuf_savers_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
extensioninidir = $(extensiondir)
extensionini_in_files = pixbuf_savers.extension.in.in
extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
sed -e "s|%LIBRARY%|`. ./$(extension_LTLIBRARIES) && echo $$dlname`|" \
$< > $@
%.extension: %.extension.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
EXTRA_DIST = $(extensionini_in_files)
DISTCLEANFILES = $(extensionini_DATA)
-include $(top_srcdir)/git.mk
SUBDIRS = ui
schemadir = @GCONF_SCHEMA_FILE_DIR@
schema_in_files = gthumb-pixbuf-savers.schemas.in
schema_DATA = $(schema_in_files:.schemas.in=.schemas)
@INTLTOOL_SCHEMAS_RULE@
if GCONF_SCHEMAS_INSTALL
install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/extensions/pixbuf_savers/data/$(schema_DATA)
endif
EXTRA_DIST = $(schema_in_files)
CLEANFILES = $(schema_DATA)
-include $(top_srcdir)/git.mk
<gconfschemafile>
<schemalist>
<schema>
<key>/schemas/apps/gthumb/ext/save_options/ask_options</key>
<applyto>/apps/gthumb/ext/save_options/ask_options</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<!-- JPEG Options -->
<schema>
<key>/schemas/apps/gthumb/save_options/jpeg/quality</key>
<applyto>/apps/gthumb/save_options/jpeg/quality</applyto>
<owner>gthumb</owner>
<type>int</type>
<default>85</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/save_options/jpeg/smoothing</key>
<applyto>/apps/gthumb/save_options/jpeg/smoothing</applyto>
<owner>gthumb</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/save_options/jpeg/optimize</key>
<applyto>/apps/gthumb/save_options/jpeg/optimize</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/save_options/jpeg/pregressive</key>
<applyto>/apps/gthumb/save_options/jpeg/pregressive</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>false</default>
<locale name="C">
<short></short>
<long>