* [gentoo-commits] proj/betagarden:master commit in: profiles/, media-gfx/cataract/, media-gfx/cataract/files/
@ 2011-06-06 1:30 Sebastian Pipping
0 siblings, 0 replies; only message in thread
From: Sebastian Pipping @ 2011-06-06 1:30 UTC (permalink / raw
To: gentoo-commits
commit: 7e1322197f2dcf66990ec75a162cd066ef400591
Author: Sebastian Pipping <sebastian <AT> pipping <DOT> org>
AuthorDate: Mon Jun 6 01:29:23 2011 +0000
Commit: Sebastian Pipping <sping <AT> gentoo <DOT> org>
CommitDate: Mon Jun 6 01:29:23 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/betagarden.git;a=commit;h=7e132219
media-gfx/cataract: 1.1.0_p20110326_p2
---
.../cataract/cataract-1.1.0_p20110326_p2.ebuild | 48 ++++
...cataract-1.1.0_p20110326-exif-orientation.patch | 286 ++++++++++++++++++++
...aract-1.1.0_p20110326-setup.xml-reporting.patch | 123 +++++++++
profiles/package.mask | 4 +
4 files changed, 461 insertions(+), 0 deletions(-)
diff --git a/media-gfx/cataract/cataract-1.1.0_p20110326_p2.ebuild b/media-gfx/cataract/cataract-1.1.0_p20110326_p2.ebuild
new file mode 100644
index 0000000..721a328
--- /dev/null
+++ b/media-gfx/cataract/cataract-1.1.0_p20110326_p2.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI="2"
+
+inherit versionator autotools
+
+MY_PV=$(get_version_component_range 1-4)
+MY_P="${PN}-${MY_PV}"
+
+DESCRIPTION="Simple static web photo gallery, designed to be clean and easily usable."
+HOMEPAGE="http://cgg.bzatek.net/"
+SRC_URI="http://www.hartwork.org/public/${MY_P}.tar.bz2"
+
+LICENSE="|| ( GPL-2 GPL-3 )"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE=""
+
+RDEPEND="dev-libs/glib
+ dev-libs/libxml2
+ media-gfx/imagemagick
+ media-gfx/exiv2"
+DEPEND="${RDEPEND}
+ dev-util/pkgconfig"
+
+S="${WORKDIR}"/${MY_P}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${MY_P}-setup.xml-reporting.patch \
+ "${FILESDIR}"/${MY_P}-exif-orientation.patch
+
+ mkdir m4 # Workaround for aclocal
+ eautoreconf
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die
+ dodoc NEWS README AUTHORS || die
+
+ # Install sample
+ rm sample/{gen.sh,Makefile*} || die
+ sed 's|<path>../../templates</path>|<path>/usr/share/cgg</path>|' \
+ -i sample/src/setup.xml || die
+ insinto /usr/share/cgg/
+ doins -r sample || die
+}
diff --git a/media-gfx/cataract/files/cataract-1.1.0_p20110326-exif-orientation.patch b/media-gfx/cataract/files/cataract-1.1.0_p20110326-exif-orientation.patch
new file mode 100644
index 0000000..553a618
--- /dev/null
+++ b/media-gfx/cataract/files/cataract-1.1.0_p20110326-exif-orientation.patch
@@ -0,0 +1,286 @@
+From c73706517be3141742f575aa2f18050aa78954f4 Mon Sep 17 00:00:00 2001
+From: Sebastian Pipping <sebastian@pipping.org>
+Date: Mon, 6 Jun 2011 02:45:56 +0200
+Subject: [PATCH 2/2] Add support for EXIF orientation tags
+
+---
+ src/generators.c | 16 ++++---
+ src/jpeg-utils.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ src/jpeg-utils.h | 8 +++-
+ 3 files changed, 118 insertions(+), 14 deletions(-)
+
+diff --git a/src/generators.c b/src/generators.c
+index 95bed37..1a865a5 100644
+--- a/src/generators.c
++++ b/src/generators.c
+@@ -1,5 +1,6 @@
+ /* Cataract - Static web photo gallery generator
+ * Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
++ * Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -158,7 +159,8 @@ generate_image (TGallerySetup *setup,
+
+ /* Do something when necessary */
+ if (res) {
+- get_image_sizes (img_src_full, &new_w, &new_h);
++ OrientationType orientation = UndefinedOrientation;
++ get_image_sizes (img_src_full, &new_w, &new_h, &orientation);
+
+ if (new_w > 0 && new_h > 0) {
+ stats_images_inc ();
+@@ -166,7 +168,7 @@ generate_image (TGallerySetup *setup,
+
+ /* Generate thumbnail */
+ g_assert (thumb_src_full != NULL);
+- get_image_sizes (thumb_src_full, &thumb_w, &thumb_h);
++ get_image_sizes (thumb_src_full, &thumb_w, &thumb_h, NULL);
+
+ if (thumb_w > 0 && thumb_h > 0) {
+ if (! item->hidden) {
+@@ -180,7 +182,7 @@ generate_image (TGallerySetup *setup,
+ calculate_sizes (setup->thumbnail_portrait_width, setup->thumbnail_portrait_height, &thumb_w, &thumb_h);
+ else
+ calculate_sizes (setup->thumbnail_landscape_width, setup->thumbnail_landscape_height, &thumb_w, &thumb_h);
+- if (! resize_image (thumb_src_full, thumb_dst, thumb_w, thumb_h, setup->thumbnail_quality, TRUE, setup->squared_thumbnail_type))
++ if (! resize_image (thumb_src_full, thumb_dst, thumb_w, thumb_h, setup->thumbnail_quality, TRUE, setup->squared_thumbnail_type, orientation))
+ log_error ("generate_image: error resizing thumbnail %s\n", thumb_src_full);
+ }
+ } else {
+@@ -215,7 +217,7 @@ generate_image (TGallerySetup *setup,
+ }
+
+ g_assert (img_src_full != NULL);
+- if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq, FALSE, 0))
++ if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq, FALSE, 0, orientation))
+ log_error ("generate_image: error resizing big image %s\n", img_src_full);
+ }
+ else {
+@@ -465,7 +467,7 @@ write_html_album (TGallerySetup *setup,
+ s2 = item_get_thumbnail_src (setup, items, item, i);
+ if (s2 != NULL) {
+ s4 = g_build_filename (path_info->dest_dir, setup->thumbnail_dir, s2, NULL);
+- get_image_sizes (s4, &img_thumb_w, &img_thumb_h);
++ get_image_sizes (s4, &img_thumb_w, &img_thumb_h, NULL);
+ g_free (s4);
+ s1 = (img_thumb_h > img_thumb_w) ? "IMG_LIST_PORTRAIT" : "IMG_LIST_LANDSCAPE";
+ }
+@@ -649,12 +651,12 @@ write_html_image (TGallerySetup *setup,
+ log_error ("write_html_image: error getting exif data from file \"%s\"\n", orig_dst);
+
+ /* Retrieve image sizes of preview and original image */
+- get_image_sizes (big_dst, &img_big_w, &img_big_h);
++ get_image_sizes (big_dst, &img_big_w, &img_big_h, NULL);
+ image_fullsize = item->force_fullsize || setup->override_nofullsize ||
+ (parent_items->fullsize && ! item->force_nofullsize) ||
+ (! item->force_nofullsize && ! parent_items->nofullsize && ! setup->nofullsize);
+ if (image_fullsize)
+- get_image_sizes (orig_dst, &img_orig_w, &img_orig_h);
++ get_image_sizes (orig_dst, &img_orig_w, &img_orig_h, NULL);
+
+ /* Get title and description from IPTC/EXIF/JPEG if not defined */
+ title = g_strdup (item->title);
+diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp
+index 55e3442..0e057b3 100644
+--- a/src/jpeg-utils.cpp
++++ b/src/jpeg-utils.cpp
+@@ -1,5 +1,6 @@
+ /* Cataract - Static web photo gallery generator
+ * Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
++ * Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -22,8 +23,6 @@
+ #include <exiv2/image.hpp>
+ #include <exiv2/exif.hpp>
+
+-#include <wand/magick-wand.h>
+-
+ #include <config.h>
+
+ #include "jpeg-utils.h"
+@@ -225,6 +224,47 @@ free_exif_data (TExifData *data)
+ }
+
+
++OrientationType get_image_orientation(const char * filename) {
++ OrientationType lookup[] = {
++ UndefinedOrientation,
++ TopLeftOrientation,
++ TopRightOrientation,
++ BottomRightOrientation,
++ BottomLeftOrientation,
++ LeftTopOrientation,
++ RightTopOrientation,
++ RightBottomOrientation,
++ LeftBottomOrientation
++ };
++
++ unsigned long val = 0;
++ try
++ {
++ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (filename);
++ g_assert (image.get() != 0);
++ image->readMetadata();
++
++ Exiv2::ExifData &exifData = image->exifData();
++ try {
++ if (! exifData.empty()) {
++ val = exifData["Exif.Image.Orientation"].toLong();
++ }
++ } catch (...) { }
++ }
++ catch (Exiv2::AnyError& e)
++ {
++ log_error ("get_exif: Caught Exiv2 exception: '%s'\n", e.what());
++ }
++
++ if (val >= sizeof(lookup)/sizeof(OrientationType)) {
++ return UndefinedOrientation;
++ } else {
++ return lookup[val];
++ }
++}
++
++
++
+ /*
+ * resize_image: resize image pointed by src and save result to dst
+ */
+@@ -233,7 +273,8 @@ resize_image (const gchar *src, const gchar *dst,
+ unsigned long size_x, unsigned long size_y,
+ int quality,
+ gboolean thumbnail,
+- ThumbnailSquareType squared_thumbnail_type)
++ ThumbnailSquareType squared_thumbnail_type,
++ OrientationType orientation)
+ {
+ MagickWand *magick_wand;
+ ExceptionType severity;
+@@ -251,6 +292,40 @@ resize_image (const gchar *src, const gchar *dst,
+ return FALSE;
+ }
+
++
++ /* http://sylvana.net/jpegcrop/exif_orientation.html */
++ PixelWand *dummy_background = NewPixelWand();
++ switch (orientation) {
++ case TopRightOrientation:
++ MagickFlopImage(magick_wand);
++ break;
++ case BottomRightOrientation:
++ MagickRotateImage(magick_wand, dummy_background, 180.0);
++ break;
++ case BottomLeftOrientation:
++ MagickFlipImage(magick_wand);
++ break;
++ case LeftTopOrientation:
++ MagickTransposeImage(magick_wand);
++ break;
++ case RightTopOrientation:
++ MagickRotateImage(magick_wand, dummy_background, 90.0);
++ break;
++ case RightBottomOrientation:
++ MagickTransverseImage(magick_wand);
++ break;
++ case LeftBottomOrientation:
++ MagickRotateImage(magick_wand, dummy_background, 270.0);
++ break;
++ case TopLeftOrientation:
++ case UndefinedOrientation:
++ default:
++ break;
++ }
++ DestroyPixelWand(dummy_background);
++ dummy_background = NULL;
++
++
+ /* Don't resize if smaller than desired size */
+ if (MagickGetImageWidth (magick_wand) > size_x ||
+ MagickGetImageHeight (magick_wand) > size_y)
+@@ -291,11 +366,11 @@ resize_image (const gchar *src, const gchar *dst,
+
+
+ /*
+- * get_image_sizes: retrieve image dimensions
++ * get_image_sizes: retrieve image dimensions (respecting EXIF orientation)
+ */
+ void
+ get_image_sizes (const gchar *img,
+- unsigned long *width, unsigned long *height)
++ unsigned long *width, unsigned long *height, OrientationType *orientation)
+ {
+ MagickWand *magick_wand;
+ ExceptionType severity;
+@@ -316,6 +391,29 @@ get_image_sizes (const gchar *img,
+ *height = MagickGetImageHeight (magick_wand);
+
+ magick_wand = DestroyMagickWand (magick_wand);
++
++ /* ImageMagick's MagickGetOrientation() seems to always return 0
++ * (even with full image read) so I use exiv2 instead */
++ const OrientationType recorded_orientation = get_image_orientation(img);
++
++ switch (recorded_orientation) {
++ case LeftTopOrientation:
++ case RightTopOrientation:
++ case RightBottomOrientation:
++ case LeftBottomOrientation:
++ { /* Swap dimensions */
++ unsigned long c = *height;
++ *height = *width;
++ *width = c;
++ }
++ break;
++ default:
++ break;
++ }
++
++ if (orientation) {
++ *orientation = recorded_orientation;
++ }
+ }
+
+
+diff --git a/src/jpeg-utils.h b/src/jpeg-utils.h
+index e5845bc..5e16502 100644
+--- a/src/jpeg-utils.h
++++ b/src/jpeg-utils.h
+@@ -1,5 +1,6 @@
+ /* Cataract - Static web photo gallery generator
+ * Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
++ * Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -19,6 +20,7 @@
+ #define __CGG__JPEG_UTILS_H__
+
+ #include <glib.h>
++#include <wand/magick-wand.h> /* for OrientationType */
+ #include "setup.h"
+
+ G_BEGIN_DECLS
+@@ -73,13 +75,15 @@ gboolean resize_image (const gchar *src, const gchar *dst,
+ unsigned long size_x, unsigned long size_y,
+ int quality,
+ gboolean thumbnail,
+- ThumbnailSquareType squared_thumbnail_type);
++ ThumbnailSquareType squared_thumbnail_type,
++ OrientationType orientation);
+
+ /*
+ * get_image_sizes: retrieve image dimensions
+ */
+ void get_image_sizes (const gchar *img,
+- unsigned long *width, unsigned long *height);
++ unsigned long *width, unsigned long *height,
++ OrientationType *orientation);
+
+ /*
+ * calculate_sizes: calculate maximal image sizes within specified limits keeping aspect ratio
+--
+1.7.5.3
+
diff --git a/media-gfx/cataract/files/cataract-1.1.0_p20110326-setup.xml-reporting.patch b/media-gfx/cataract/files/cataract-1.1.0_p20110326-setup.xml-reporting.patch
new file mode 100644
index 0000000..c530149
--- /dev/null
+++ b/media-gfx/cataract/files/cataract-1.1.0_p20110326-setup.xml-reporting.patch
@@ -0,0 +1,123 @@
+From 43577828a097c6f0cc0fe651e3d78b7a9259e248 Mon Sep 17 00:00:00 2001
+From: Sebastian Pipping <sebastian@pipping.org>
+Date: Sun, 5 Jun 2011 22:01:09 +0200
+Subject: [PATCH 1/2] Improve error reporting for missing setup.xml, stick to
+ first setup.xml found
+
+---
+ src/cgg.c | 18 ++++++++++++++++--
+ src/setup.c | 39 +++++++++++++++++----------------------
+ 2 files changed, 33 insertions(+), 24 deletions(-)
+
+diff --git a/src/cgg.c b/src/cgg.c
+index 0f72fb3..ca980ed 100644
+--- a/src/cgg.c
++++ b/src/cgg.c
+@@ -1,5 +1,6 @@
+ /* Cataract - Static web photo gallery generator
+ * Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
++ * Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -109,6 +110,7 @@ main (int argc, char* argv[])
+ time_t time_stop;
+ gchar *s;
+ TPathInfo *path_info;
++ gchar *setup_xml_path = NULL;
+
+ /*
+ * this initialize the library and check potential ABI mismatches
+@@ -136,11 +138,23 @@ main (int argc, char* argv[])
+ }
+
+ /* Read gallery settings */
+- setup = find_setup_xml ();
++ setup = find_setup_xml (&setup_xml_path);
+ if (! setup) {
+- fprintf (stderr, "error: could not parse gallery settings file\n");
++ if (! setup_xml_path) {
++ gchar *cwd = g_get_current_dir ();
++ gchar *home_cgg = g_build_filename (g_getenv ("HOME"), ".cgg", NULL);
++ gchar *datadir_cgg = g_build_filename (DATADIR, "cgg", NULL);
++ fprintf (stderr, "error: could not find setup.xml in\n1) %s\n2) %s\n3) %s\n", cwd, home_cgg, datadir_cgg);
++ g_free (datadir_cgg);
++ g_free (home_cgg);
++ g_free (cwd);
++ }
+ return -2;
+ }
++ if (setup_xml_path) {
++ g_free(setup_xml_path);
++ setup_xml_path = NULL;
++ }
+
+ setup->real_templates_dir = find_templates_directory (setup);
+ if (setup->real_templates_dir == NULL) {
+diff --git a/src/setup.c b/src/setup.c
+index 68c3cd3..71553c7 100644
+--- a/src/setup.c
++++ b/src/setup.c
+@@ -1,5 +1,6 @@
+ /* Cataract - Static web photo gallery generator
+ * Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
++ * Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+@@ -41,36 +42,30 @@
+ * find_setup_xml: try to find setup.xml in standard paths
+ */
+ TGallerySetup *
+-find_setup_xml ()
++find_setup_xml (gchar **setup_xml_path)
+ {
+- gchar *pth;
+ gchar *cwd;
+- TGallerySetup *setup;
+-
+- setup = NULL;
+ cwd = g_get_current_dir ();
+- pth = g_build_filename (cwd, SETUP_XML, NULL);
++
++ *setup_xml_path = g_build_filename (cwd, SETUP_XML, NULL);
+ g_free (cwd);
+
+- if (g_access (pth, R_OK) == 0)
+- setup = parse_setup_xml (pth);
+- g_free (pth);
++ if (g_access (*setup_xml_path, R_OK) == 0)
++ return parse_setup_xml (*setup_xml_path);
+
+- if (! setup) {
+- pth = g_build_filename (g_getenv ("HOME"), ".cgg", SETUP_XML, NULL);
+- if (g_access (pth, R_OK) == 0)
+- setup = parse_setup_xml (pth);
+- g_free (pth);
+- }
++ g_free (*setup_xml_path);
++ *setup_xml_path = g_build_filename (g_getenv ("HOME"), ".cgg", SETUP_XML, NULL);
++ if (g_access (*setup_xml_path, R_OK) == 0)
++ return parse_setup_xml (*setup_xml_path);
+
+- if (! setup) {
+- pth = g_build_filename (DATADIR, "cgg", SETUP_XML, NULL);
+- if (g_access (pth, R_OK) == 0)
+- setup = parse_setup_xml (pth);
+- g_free (pth);
+- }
++ g_free (*setup_xml_path);
++ *setup_xml_path = g_build_filename (DATADIR, "cgg", SETUP_XML, NULL);
++ if (g_access (*setup_xml_path, R_OK) == 0)
++ return parse_setup_xml (*setup_xml_path);
+
+- return setup;
++ g_free (*setup_xml_path);
++ *setup_xml_path = NULL;
++ return NULL;
+ }
+
+
+--
+1.7.5.3
+
diff --git a/profiles/package.mask b/profiles/package.mask
index 17f8b40..814916e 100644
--- a/profiles/package.mask
+++ b/profiles/package.mask
@@ -1 +1,5 @@
~sys-apps/dbus-9999
+
+# 2011-06-06 Sebastian Pipping <sping@gentoo.org>
+# Experimental downstream patches
+=media-gfx/cataract-1.1.0_p20110326_p2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-06 1:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 1:30 [gentoo-commits] proj/betagarden:master commit in: profiles/, media-gfx/cataract/, media-gfx/cataract/files/ Sebastian Pipping
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox