Mercurial > geeqie.yaz
comparison src/thumb.c @ 839:14520c3a91f8
rotate thumbnails by exif
author | nadvornik |
---|---|
date | Sun, 15 Jun 2008 21:52:15 +0000 |
parents | 9bd49e725ad3 |
children | 64ef209bcded |
comparison
equal
deleted
inserted
replaced
838:9bd49e725ad3 | 839:14520c3a91f8 |
---|---|
18 #include "image-load.h" | 18 #include "image-load.h" |
19 #include "filedata.h" | 19 #include "filedata.h" |
20 #include "pixbuf_util.h" | 20 #include "pixbuf_util.h" |
21 #include "thumb_standard.h" | 21 #include "thumb_standard.h" |
22 #include "ui_fileops.h" | 22 #include "ui_fileops.h" |
23 #include "exif.h" | |
23 | 24 |
24 #include <utime.h> | 25 #include <utime.h> |
25 | 26 |
26 | 27 |
27 static void thumb_loader_error_cb(ImageLoader *il, gpointer data); | 28 static void thumb_loader_error_cb(ImageLoader *il, gpointer data); |
145 { | 146 { |
146 ThumbLoader *tl = data; | 147 ThumbLoader *tl = data; |
147 GdkPixbuf *pixbuf; | 148 GdkPixbuf *pixbuf; |
148 gint pw, ph; | 149 gint pw, ph; |
149 gint save; | 150 gint save; |
151 GdkPixbuf *rotated = NULL; | |
150 | 152 |
151 DEBUG_1("thumb done: %s", tl->fd->path); | 153 DEBUG_1("thumb done: %s", tl->fd->path); |
152 | 154 |
153 pixbuf = image_loader_get_pixbuf(tl->il); | 155 pixbuf = image_loader_get_pixbuf(tl->il); |
154 if (!pixbuf) | 156 if (!pixbuf) |
156 DEBUG_1("...but no pixbuf: %s", tl->fd->path); | 158 DEBUG_1("...but no pixbuf: %s", tl->fd->path); |
157 thumb_loader_error_cb(tl->il, tl); | 159 thumb_loader_error_cb(tl->il, tl); |
158 return; | 160 return; |
159 } | 161 } |
160 | 162 |
163 | |
164 if (!tl->cache_hit && options->image.exif_rotate_enable) | |
165 { | |
166 if (!tl->fd->exif_orientation) | |
167 { | |
168 ExifData *exif = exif_read_fd(tl->fd); | |
169 gint orientation; | |
170 | |
171 if (exif && exif_get_integer(exif, "Exif.Image.Orientation", &orientation)) | |
172 tl->fd->exif_orientation = orientation; | |
173 else | |
174 tl->fd->exif_orientation = 1; | |
175 } | |
176 | |
177 rotated = pixbuf_apply_orientation(pixbuf, tl->fd->exif_orientation); | |
178 pixbuf = rotated; | |
179 } | |
180 | |
161 pw = gdk_pixbuf_get_width(pixbuf); | 181 pw = gdk_pixbuf_get_width(pixbuf); |
162 ph = gdk_pixbuf_get_height(pixbuf); | 182 ph = gdk_pixbuf_get_height(pixbuf); |
163 | 183 |
164 if (tl->cache_hit && pw != tl->max_w && ph != tl->max_h) | 184 if (tl->cache_hit && pw != tl->max_w && ph != tl->max_h) |
165 { | 185 { |
215 gdk_pixbuf_ref(tl->fd->pixbuf); | 235 gdk_pixbuf_ref(tl->fd->pixbuf); |
216 } | 236 } |
217 save = il->shrunk; | 237 save = il->shrunk; |
218 } | 238 } |
219 | 239 |
240 if (rotated) gdk_pixbuf_unref(rotated); | |
241 | |
220 /* save it ? */ | 242 /* save it ? */ |
221 if (tl->cache_enable && save) | 243 if (tl->cache_enable && save) |
222 { | 244 { |
223 thumb_loader_save_to_cache(tl); | 245 thumb_loader_save_to_cache(tl); |
224 } | 246 } |