aboutsummaryrefslogtreecommitdiffstats
path: root/opening.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-10-14 18:54:48 +0200
committerMattias Andrée <m@maandree.se>2026-10-14 18:54:48 +0200
commit6bbfc093885043abdfa18826511ee053e52d08fa (patch)
tree2d76b446617658412930ba4147e0d2db837d000a /opening.c
parentFourth commit (diff)
downloadgbild-master.tar.gz
gbild-master.tar.bz2
gbild-master.tar.xz
Fifth commitHEAD0.1master
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'opening.c')
-rw-r--r--opening.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/opening.c b/opening.c
index 1552b18..54228b1 100644
--- a/opening.c
+++ b/opening.c
@@ -81,6 +81,18 @@ get_raster_dpi_option(GdkPixbuf *raster, const char *name, double *dpi)
return 1;
}
+static int
+parse_orientation(const char *s)
+{
+ char c;
+ if (!s) return 0;
+ while (isspace(*s)) s++;
+ c = *s;
+ if (!c) return 0;
+ while (isspace(*s)) s++;
+ return (!*s || c < '1' || c > '8') ? 0 : (int)c - '0';
+}
+
int
load_image(struct file *file, int errors_to_stderr)
{
@@ -95,6 +107,7 @@ load_image(struct file *file, int errors_to_stderr)
unsigned char *buffer = NULL;
size_t size;
int fd, ret = 1;
+ int orientation;
if (!file)
return 0;
@@ -140,11 +153,17 @@ load_image(struct file *file, int errors_to_stderr)
file->image.vector = vector;
vector = NULL;
+ if (file->image.vector) {
+ /* TODO get dimensions and dpi from file->image.vector */
+ }
file->image.width = gdk_pixbuf_get_width(file->image.raster);
file->image.height = gdk_pixbuf_get_height(file->image.raster);
file->image.has_x_dpi = get_raster_dpi_option(file->image.raster, "x-dpi", &file->image.x_dpi);
file->image.has_y_dpi = get_raster_dpi_option(file->image.raster, "y-dpi", &file->image.y_dpi);
+ orientation = parse_orientation(gdk_pixbuf_get_option(file->image.raster, "orientation"));
+ file->image.embedded_transformation = orientation_to_transformation(orientation);
+
if (file->exif_tags) {
g_strfreev(file->exif_tags);
file->exif_tags = NULL;