gthumb r2233 - in trunk: . libgthumb src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2233 - in trunk: . libgthumb src
- Date: Tue, 29 Jan 2008 18:36:32 +0000 (GMT)
Author: mjc
Date: Tue Jan 29 18:36:32 2008
New Revision: 2233
URL: http://svn.gnome.org/viewvc/gthumb?rev=2233&view=rev
Log:
2008-01-29 Michael J. Chudobiak <mjc svn gnome org>
* libgthumb/file-utils.c: (gth_pixbuf_new_from_file):
* libgthumb/gth-exif-utils.c: (get_orientation_from_fd),
(update_metadata):
* libgthumb/gth-exif-utils.h:
* src/catalog-web-exporter.c: (export__copy_image):
* src/dlg-jpegtran.c: (apply_transformation__trim_response),
(apply_transformation__step2):
* src/dlg-photo-importer.c: (adjust_orientation__step):
Replaced read_orientation_field with exiv2-based
get_orientation_from_fd. Delete gth_minimal_exif_tag_read.
All metadata reads are through exiv2, now. Next stop: writes.
Modified:
trunk/ChangeLog
trunk/libgthumb/file-utils.c
trunk/libgthumb/gth-exif-utils.c
trunk/libgthumb/gth-exif-utils.h
trunk/src/catalog-web-exporter.c
trunk/src/dlg-jpegtran.c
trunk/src/dlg-photo-importer.c
Modified: trunk/libgthumb/file-utils.c
==============================================================================
--- trunk/libgthumb/file-utils.c (original)
+++ trunk/libgthumb/file-utils.c Tue Jan 29 18:36:32 2008
@@ -3444,7 +3444,7 @@
GthTransform orientation;
GthTransform transform = GTH_TRANSFORM_NONE;
- orientation = read_orientation_field (local_file);
+ orientation = get_orientation_from_fd (file);
transform = (orientation >= 1 && orientation <= 8 ? orientation : GTH_TRANSFORM_NONE);
debug (DEBUG_INFO, "read_orientation_field says orientation is %d, transform needed is %d.\n\r", orientation, transform);
Modified: trunk/libgthumb/gth-exif-utils.c
==============================================================================
--- trunk/libgthumb/gth-exif-utils.c (original)
+++ trunk/libgthumb/gth-exif-utils.c Tue Jan 29 18:36:32 2008
@@ -88,12 +88,12 @@
const char *_MAKE_TAG_NAMES[] = {
"Exif.Image.Make",
- "Xmp.exif.Make",
+ "Xmp.tiff.Make",
NULL };
const char *_MODEL_TAG_NAMES[] = {
"Exif.Image.Model",
- "Xmp.exif.Model",
+ "Xmp.tiff.Model",
NULL };
const char *_FLASH_TAG_NAMES[] = {
@@ -101,6 +101,10 @@
"Xmp.exif.Flash",
NULL };
+const char *_ORIENTATION_TAG_NAMES[] = {
+ "Exif.Image.Orientation",
+ "Xmp.tiff.Orientation",
+ NULL };
/* if you add something here, also update the matching enum in gth-exif-utils.h */
const char **TAG_NAME_SETS[] = {
@@ -113,7 +117,8 @@
_SHUTTERSPEED_TAG_NAMES,
_MAKE_TAG_NAMES,
_MODEL_TAG_NAMES,
- _FLASH_TAG_NAMES
+ _FLASH_TAG_NAMES,
+ _ORIENTATION_TAG_NAMES
};
@@ -217,6 +222,39 @@
}
+GthTransform
+get_orientation_from_fd (FileData *fd)
+{
+ char *orientation_string = NULL;
+ GthTransform result = GTH_TRANSFORM_NONE;
+
+ orientation_string = get_metadata_string_from_fd (fd, TAG_NAME_SETS[ORIENTATION_TAG_NAMES]);
+
+ if (orientation_string == NULL)
+ result = GTH_TRANSFORM_NONE;
+ else if (!strcmp (orientation_string, "top, left"))
+ result = GTH_TRANSFORM_NONE;
+ else if (!strcmp (orientation_string, "top, right"))
+ result = GTH_TRANSFORM_FLIP_H;
+ else if (!strcmp (orientation_string, "bottom, right"))
+ result = GTH_TRANSFORM_ROTATE_180;
+ else if (!strcmp (orientation_string, "bottom, left"))
+ result = GTH_TRANSFORM_FLIP_V;
+ else if (!strcmp (orientation_string, "left, top"))
+ result = GTH_TRANSFORM_TRANSPOSE;
+ else if (!strcmp (orientation_string, "right, top"))
+ result = GTH_TRANSFORM_ROTATE_90;
+ else if (!strcmp (orientation_string, "right, bottom"))
+ result = GTH_TRANSFORM_TRANSVERSE;
+ else if (!strcmp (orientation_string, "left, bottom"))
+ result = GTH_TRANSFORM_ROTATE_270;
+
+ g_free (orientation_string);
+
+ return result;
+}
+
+
char *
get_metadata_string_from_fd (FileData *fd, const char *tagnames[])
{
@@ -570,17 +608,6 @@
int
-gth_minimal_exif_tag_read (const char *local_file,
- ExifTag etag,
- void *data,
- int size)
-{
- debug (DEBUG_INFO, "gth_minimal_exif_tag_read(%s, %04x, %08x, %d)\n", local_file, etag, data, size);
- return gth_minimal_exif_tag_action (local_file, etag, data, size, 0);
-}
-
-
-int
gth_minimal_exif_tag_write (const char *local_file,
ExifTag etag,
void *data,
@@ -591,24 +618,6 @@
}
-GthTransform
-read_orientation_field (const char *local_file)
-{
- ExifShort orientation;
- guint16 tf;
-
- if (local_file == NULL)
- return GTH_TRANSFORM_NONE;
-
- gth_minimal_exif_tag_read (local_file, EXIF_TAG_ORIENTATION, &tf, 2);
- orientation = (GthTransform) tf;
- if ((orientation >= 1) && (orientation <= 8))
- return orientation;
- else
- return GTH_TRANSFORM_NONE;
-}
-
-
void
write_orientation_field (const char *local_file,
GthTransform transform)
@@ -673,16 +682,23 @@
void
update_metadata (FileData *fd)
{
- char *local_file = NULL;
-
+ char *local_file;
+
/* Have we already read in the metadata? */
if (fd->exif_data_loaded == TRUE)
return;
+ local_file = get_cache_filename_from_uri (fd->path);
+
+ if (fd->mime_type == NULL)
+ file_data_update_mime_type (fd, FALSE);
+
+ g_assert (fd->mime_type != NULL);
+
if (mime_type_is_image (fd->mime_type))
- fd->metadata = gth_read_exiv2 (fd->path, fd->metadata);
+ fd->metadata = gth_read_exiv2 (local_file, fd->metadata);
else if (mime_type_is_video (fd->mime_type))
- fd->metadata = gth_read_gstreamer (fd->path, fd->metadata);
+ fd->metadata = gth_read_gstreamer (local_file, fd->metadata);
/* Sort alphabetically by tag name. The "position" value will
override this sorting, if position is non-zero. */
@@ -690,5 +706,7 @@
fd->exif_data_loaded = TRUE;
fd->exif_time = get_metadata_time_from_fd (fd);
+ g_free (local_file);
+
return;
}
Modified: trunk/libgthumb/gth-exif-utils.h
==============================================================================
--- trunk/libgthumb/gth-exif-utils.h (original)
+++ trunk/libgthumb/gth-exif-utils.h Tue Jan 29 18:36:32 2008
@@ -86,7 +86,8 @@
SHUTTERSPEED_TAG_NAMES,
MAKE_TAG_NAMES,
MODEL_TAG_NAMES,
- FLASH_TAG_NAMES
+ FLASH_TAG_NAMES,
+ ORIENTATION_TAG_NAMES
};
@@ -105,11 +106,6 @@
ExifTag etag,
void *data,
int size);
-int gth_minimal_exif_tag_read (const char *filename,
- ExifTag etag,
- void *data,
- int size);
-GthTransform read_orientation_field (const char *path);
void write_orientation_field (const char *filename,
GthTransform transform);
GList * gth_read_exiv2 (const char *filename,
Modified: trunk/src/catalog-web-exporter.c
==============================================================================
--- trunk/src/catalog-web-exporter.c (original)
+++ trunk/src/catalog-web-exporter.c Tue Jan 29 18:36:32 2008
@@ -2530,20 +2530,19 @@
if (result == GNOME_VFS_OK) {
if (image_is_jpeg (temp_destination)) {
GthTransform transform;
-
- transform = read_orientation_field (get_file_path_from_uri (temp_destination));
+
+ FileData *fd;
+ fd = file_data_new (temp_destination, NULL);
+ transform = get_orientation_from_fd (fd);
if (transform > 1) {
- FileData *fd;
-
- fd = file_data_new (temp_destination, NULL);
- file_data_update (fd);
apply_transformation_jpeg (fd,
transform,
JPEG_MCU_ACTION_TRIM,
NULL);
- file_data_unref (fd);
}
+
+ file_data_unref (fd);
}
}
Modified: trunk/src/dlg-jpegtran.c
==============================================================================
--- trunk/src/dlg-jpegtran.c (original)
+++ trunk/src/dlg-jpegtran.c Tue Jan 29 18:36:32 2008
@@ -273,7 +273,7 @@
GthTransform required_transform;
local_file = get_cache_filename_from_uri (file->path);
- image_orientation = read_orientation_field (local_file);
+ image_orientation = get_orientation_from_fd (file);
required_transform = get_next_transformation (image_orientation, at_data->data->transform);
apply_transformation_jpeg (file, required_transform, action, NULL);
@@ -297,7 +297,7 @@
gboolean go_on = TRUE;
local_file = get_cache_filename_from_uri (file->path);
- image_orientation = read_orientation_field (local_file);
+ image_orientation = get_orientation_from_fd (file);
required_transform = get_next_transformation (image_orientation, at_data->data->transform);
if (mime_type_is (file->mime_type, "image/jpeg")) {
if (image_orientation && ! eel_gconf_get_boolean (PREF_ROTATE_RESET_EXIF_ORIENTATION, TRUE))
Modified: trunk/src/dlg-photo-importer.c
==============================================================================
--- trunk/src/dlg-photo-importer.c (original)
+++ trunk/src/dlg-photo-importer.c Tue Jan 29 18:36:32 2008
@@ -1583,7 +1583,7 @@
g_free (data->msg_text);
data->msg_text = g_strdup_printf (_("Adjusting orientation of \'%s\'."), file_name_from_path (fd->path));
- transform = read_orientation_field (get_file_path_from_uri (fd->path));
+ transform = get_orientation_from_fd (fd);
if (image_is_jpeg (uri))
success = apply_transformation_jpeg (fd, transform, JPEG_MCU_ACTION_DONT_TRIM, NULL);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]