diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-12-28 23:10:45 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-12-28 23:29:58 +0100 |
commit | 98bdab443adfbf4d6ecc485874806016771ddbf6 (patch) | |
tree | 993a4b3a0db308b83fe26eefe4b648ed8d7d56af /fiv-io.c | |
parent | bf47782f0a4720da8b6aeb39cfc128b6b26ded6e (diff) | |
download | fiv-98bdab443adfbf4d6ecc485874806016771ddbf6.tar.gz fiv-98bdab443adfbf4d6ecc485874806016771ddbf6.tar.xz fiv-98bdab443adfbf4d6ecc485874806016771ddbf6.zip |
Hardcode Exif orientation in thumbnails
Diffstat (limited to 'fiv-io.c')
-rw-r--r-- | fiv-io.c | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -2627,6 +2627,61 @@ fiv_io_save(cairo_surface_t *page, cairo_surface_t *frame, FivIoProfile target, // --- Metadata ---------------------------------------------------------------- +gboolean +fiv_io_orientation_is_sideways(FivIoOrientation orientation) +{ + switch (orientation) { + case FivIoOrientation90: + case FivIoOrientationMirror90: + case FivIoOrientation270: + case FivIoOrientationMirror270: + return TRUE; + default: + return FALSE; + } +} + +cairo_matrix_t +fiv_io_orientation_matrix( + FivIoOrientation orientation, double width, double height) +{ + cairo_matrix_t matrix = {}; + cairo_matrix_init_identity(&matrix); + switch (orientation) { + case FivIoOrientation90: + cairo_matrix_rotate(&matrix, -M_PI_2); + cairo_matrix_translate(&matrix, -width, 0); + break; + case FivIoOrientation180: + cairo_matrix_scale(&matrix, -1, -1); + cairo_matrix_translate(&matrix, -width, -height); + break; + case FivIoOrientation270: + cairo_matrix_rotate(&matrix, +M_PI_2); + cairo_matrix_translate(&matrix, 0, -height); + break; + case FivIoOrientationMirror0: + cairo_matrix_scale(&matrix, -1, +1); + cairo_matrix_translate(&matrix, -width, 0); + break; + case FivIoOrientationMirror90: + cairo_matrix_rotate(&matrix, +M_PI_2); + cairo_matrix_scale(&matrix, -1, +1); + cairo_matrix_translate(&matrix, -width, -height); + break; + case FivIoOrientationMirror180: + cairo_matrix_scale(&matrix, +1, -1); + cairo_matrix_translate(&matrix, 0, -height); + break; + case FivIoOrientationMirror270: + cairo_matrix_rotate(&matrix, -M_PI_2); + cairo_matrix_scale(&matrix, -1, +1); + default: + break; + } + return matrix; +} + FivIoOrientation fiv_io_exif_orientation(const guint8 *tiff, gsize len) { |