+From de2f3edd669f00160c3584149f4ba871970704e3 Mon Sep 17 00:00:00 2001
+From: Leonardo Sobral Cunha <leonardo.cunha@openbossa.org>
+Date: Wed, 28 May 2008 18:30:52 -0300
+Subject: [PATCH] Add support for custom size thumbnails
+
+The width or height of the custom size may be negative,
+indicating that this orientation has no size limit.
+You must also set the dir name relative to $HOME/.thumbnails .
+---
+ src/lib/Epsilon.c | 59 ++++++++++++++++++++++++++++++++++++++++++++--------
+ src/lib/Epsilon.h | 6 +++++
+ 2 files changed, 56 insertions(+), 9 deletions(-)
+
diff --git a/src/lib/Epsilon.c b/src/lib/Epsilon.c
-index c1d769e..e01f714 100644
+index e293a9e..cf1969e 100644
--- a/src/lib/Epsilon.c
+++ b/src/lib/Epsilon.c
-@@ -23,6 +23,9 @@
- #ifdef HAVE_EPEG_H
- #include <Epeg.h>
+@@ -25,6 +25,7 @@
#endif
-+#define THUMB_HEIGHT_CANOLA 96
-+#define THUMB_WIDTH_CANOLA 192
-+#define THUMB_SIZE_CANOLA 192
#define THUMB_SIZE_NORMAL 128
#define THUMB_SIZE_LARGE 256
++#define THUMB_SIZE_CUSTOM 0
#define THUMB_SIZE_FAIL -1
-@@ -38,9 +41,11 @@
+ #include "exiftags/exif.h"
+
+@@ -38,9 +39,11 @@
static char *PATH_DIR_LARGE = NULL;
static char *PATH_DIR_NORMAL = NULL;
-+static char *PATH_DIR_CANOLA = NULL;
++static char *PATH_DIR_CUSTOM = NULL;
static char *PATH_DIR_FAIL = NULL;
static unsigned LEN_DIR_LARGE = 0;
static unsigned LEN_DIR_NORMAL = 0;
-+static unsigned LEN_DIR_CANOLA = 0;
++static unsigned LEN_DIR_CUSTOM = 0;
static unsigned LEN_DIR_FAIL = 0;
-@@ -153,6 +158,11 @@ epsilon_init (void)
- PATH_DIR_NORMAL = strdup(buf);
- LEN_DIR_NORMAL = strlen(buf);
- }
-+ if (!PATH_DIR_CANOLA) {
-+ strncpy(buf + base_len, "/canola", PATH_MAX - base_len);
-+ PATH_DIR_CANOLA = strdup(buf);
-+ LEN_DIR_CANOLA = strlen(buf);
-+ }
- if (!PATH_DIR_FAIL) {
- strncpy(buf + base_len, "/fail/epsilon", PATH_MAX - base_len);
- PATH_DIR_FAIL = strdup(buf);
-@@ -161,6 +171,7 @@ epsilon_init (void)
-
- ecore_file_mkpath(PATH_DIR_LARGE);
- ecore_file_mkpath(PATH_DIR_NORMAL);
-+ ecore_file_mkpath(PATH_DIR_CANOLA);
- ecore_file_mkpath(PATH_DIR_FAIL);
-
- plugins_mime = ecore_hash_new(ecore_str_hash, ecore_str_compare);
-@@ -446,6 +457,11 @@ _epsilon_file_name(unsigned thumb_size, const char *hash, const char *ext, char
+@@ -446,6 +449,11 @@ _epsilon_file_name(unsigned thumb_size, const char *hash, const char *ext, char
dir = PATH_DIR_NORMAL;
dir_len = LEN_DIR_NORMAL;
}
-+ else if (thumb_size == THUMB_SIZE_CANOLA)
++ else if (thumb_size == THUMB_SIZE_CUSTOM)
+ {
-+ dir = PATH_DIR_CANOLA;
-+ dir_len = LEN_DIR_CANOLA;
++ dir = PATH_DIR_CUSTOM;
++ dir_len = LEN_DIR_CUSTOM;
+ }
else
{
dir = PATH_DIR_FAIL;
-@@ -563,10 +579,10 @@ epsilon_generate (Epsilon * e)
+@@ -474,7 +482,7 @@ _epsilon_exists_ext_int(unsigned thumb_size, const char *hash, const char *ext,
+ static int
+ _epsilon_exists_ext(Epsilon *e, const char *ext, char *path, int path_size, time_t *mtime)
+ {
+- if (_epsilon_exists_ext_int(e->tw, e->hash, ext, path, path_size, mtime))
++ if (_epsilon_exists_ext_int(e->tsize, e->hash, ext, path, path_size, mtime))
+ return 1;
- if (!e || !e->src || !e->hash)
- return (EPSILON_FAIL);
--
-+
- tw = e->tw;
- th = e->th;
--
-+
- #ifdef HAVE_EPEG_H
- len = strlen (e->src);
- if ((len > 4) &&
-@@ -575,7 +591,8 @@ epsilon_generate (Epsilon * e)
- _epsilon_file_name(e->tw, e->hash, "jpg", outfile, sizeof(outfile));
- epeg_thumbnail_comments_get (im, &info);
- epeg_size_get (im, &iw, &ih);
-- if (iw > ih)
-+ /* XXX - hack to force fixed height in case of tw != th (canola) */
-+ if (iw > ih && tw == th)
- {
- th = ((unsigned long) e->tw * ih) / iw;
- if (th < 1) th = 1;
-@@ -697,7 +714,8 @@ epsilon_generate (Epsilon * e)
- {
- iw = imlib_image_get_width ();
- ih = imlib_image_get_height ();
-- if (iw > ih)
-+ /* XXX - hack to force fixed height in case of tw != th (canola) */
-+ if (iw > ih && tw == th)
+ return _epsilon_exists_ext_int(THUMB_SIZE_FAIL, e->hash, ext, path, path_size, mtime);
+@@ -601,9 +609,12 @@ epsilon_generate (Epsilon * e)
+ evas_object_image_data_update_add(im, 0, 0, iw, ih);
+ if ((iw > 0) && (ih > 0))
{
- th = ((unsigned long) e->tw * ih) / iw;
- if (th < 1) th = 1;
-@@ -738,7 +756,7 @@ void
- epsilon_thumb_size(Epsilon *e, Epsilon_Thumb_Size size)
- {
- if (!e) return;
--
-+
- switch (size)
- {
+- ww = e->tw;
+- hh = (e->tw * ih) / iw;
+- if (hh > e->th)
++ if ((iw > ih && e->tw > 0) || e->th <= 0)
++ {
++ ww = e->tw;
++ hh = (e->tw * ih) / iw;
++ }
++ else
+ {
+ hh = e->th;
+ ww = (e->th * iw) / ih;
+@@ -647,9 +658,12 @@ epsilon_generate (Epsilon * e)
+ alpha = evas_object_image_alpha_get(im);
+ if ((iw > 0) && (ih > 0))
+ {
+- ww = e->tw;
+- hh = (e->tw * ih) / iw;
+- if (hh > e->th)
++ if ((iw > ih && e->tw > 0) || e->th <= 0)
++ {
++ ww = e->tw;
++ hh = (e->tw * ih) / iw;
++ }
++ else
+ {
+ hh = e->th;
+ ww = (e->th * iw) / ih;
+@@ -667,7 +681,7 @@ epsilon_generate (Epsilon * e)
+ if (data)
+ {
+ snprintf(buf, sizeof(buf), "file://%s", e->src);
+- _epsilon_file_name(e->tw, e->hash, "png", buf2, sizeof(buf2));
++ _epsilon_file_name(e->tsize, e->hash, "png", buf2, sizeof(buf2));
+ /* this is wrong - but hey! good enough? */
+ if (ext) snprintf(buf3, sizeof(buf3), "image/%s", ext);
+ else snprintf(buf3, sizeof(buf3), "image/png");
+@@ -706,14 +720,41 @@ epsilon_thumb_size(Epsilon *e, Epsilon_Thumb_Size size)
case EPSILON_THUMB_NORMAL:
-@@ -749,7 +767,11 @@ epsilon_thumb_size(Epsilon *e, Epsilon_Thumb_Size size)
+ e->tw = THUMB_SIZE_NORMAL;
+ e->th = THUMB_SIZE_NORMAL;
++ e->tsize = THUMB_SIZE_NORMAL;
+ break;
+ case EPSILON_THUMB_LARGE:
e->tw = THUMB_SIZE_LARGE;
e->th = THUMB_SIZE_LARGE;
++ e->tsize = THUMB_SIZE_LARGE;
break;
- }
-+ case EPSILON_THUMB_CANOLA:
-+ e->tw = THUMB_WIDTH_CANOLA;
-+ e->th = THUMB_HEIGHT_CANOLA;
-+ break;
+ }
}
++void
++epsilon_custom_thumb_size (Epsilon * e, int w, int h, const char *dir)
++{
++ char buf[PATH_MAX];
++ int base_len;
++ char *home;
++
++ if (e && (w > 0 || h > 0))
++ {
++ e->tw = w;
++ e->th = h;
++ e->tsize = THUMB_SIZE_CUSTOM;
++
++ home = getenv("HOME");
++ base_len = snprintf(buf, sizeof(buf), "%s/.thumbnails/", home);
++ strncpy(buf + base_len, dir, PATH_MAX - base_len);
++
++ if (PATH_DIR_CUSTOM)
++ free(PATH_DIR_CUSTOM);
++
++ PATH_DIR_CUSTOM = strdup(buf);
++ LEN_DIR_CUSTOM = strlen(buf);
++ ecore_file_mkpath(PATH_DIR_CUSTOM);
++ }
++}
+ #ifdef HAVE_PNG_H
+ static FILE *
diff --git a/src/lib/Epsilon.h b/src/lib/Epsilon.h
-index 90a51b3..05ff2f7 100644
+index 90a51b3..166f78c 100644
--- a/src/lib/Epsilon.h
+++ b/src/lib/Epsilon.h
-@@ -58,7 +58,8 @@ typedef struct _Epsilon_Info Epsilon_Info;
- enum _Epsilon_Thumb_Size
- {
- EPSILON_THUMB_NORMAL,
-- EPSILON_THUMB_LARGE
-+ EPSILON_THUMB_LARGE,
-+ EPSILON_THUMB_CANOLA
+@@ -42,6 +42,7 @@ struct _Epsilon
+ char *key;
+ int w, h;
+ int tw, th;
++ int tsize;
};
+ typedef struct _Epsilon Epsilon;
- typedef enum _Epsilon_Thumb_Size Epsilon_Thumb_Size;
+@@ -96,6 +97,11 @@ EAPI int epsilon_generate (Epsilon * e);
+ EAPI void epsilon_thumb_size(Epsilon *e, Epsilon_Thumb_Size size);
+
+ /*
++ * set a custom thumb size
++ */
++EAPI void epsilon_custom_thumb_size(Epsilon *e, int w, int h, const char *dir);
++
++/*
+ * get the meta information associated with the epsilon
+ */
+ EAPI Epsilon_Info *epsilon_info_get (Epsilon * e);
--
-1.5.3.6
+1.5.4.3
-diff -upr python-epsilon.orig/epsilon/epsilon.c_epsilon.pyx python-epsilon/epsilon/epsilon.c_epsilon.pyx
---- python-epsilon.orig/epsilon/epsilon.c_epsilon.pyx 2007-11-24 22:50:53.000000000 -0300
-+++ python-epsilon/epsilon/epsilon.c_epsilon.pyx 2007-12-10 18:06:21.000000000 -0300
-@@ -8,6 +8,7 @@ def init():
-
- EPSILON_THUMB_NORMAL = 0
- EPSILON_THUMB_LARGE = 1
-+EPSILON_THUMB_CANOLA = 2
-
- cdef class Epsilon:
- """Epsilon thumbnail generator.
-@@ -21,7 +22,8 @@ cdef class Epsilon:
+From 71e5febf2f353efd9bff187c94d737760ba01b12 Mon Sep 17 00:00:00 2001
+From: Leonardo Sobral Cunha <leonardo.cunha@openbossa.org>
+Date: Sat, 24 Nov 2007 18:50:54 -0300
+Subject: [PATCH] Support for epsilon api for creating custom sized thumbs
+
+---
+ epsilon/epsilon.c_epsilon.pyx | 11 +++++++++--
+ epsilon/epsilon.request.pyx | 6 ++++--
+ include/epsilon/c_epsilon.pxd | 1 +
+ 3 files changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/epsilon/epsilon.c_epsilon.pyx b/epsilon/epsilon.c_epsilon.pyx
+index cfd58ca..8550884 100644
+--- a/epsilon/epsilon.c_epsilon.pyx
++++ b/epsilon/epsilon.c_epsilon.pyx
+@@ -21,7 +21,7 @@ cdef class Epsilon:
"""Epsilon constructor.
@parm path: full path of image to process.
- @parm thumb_size: one of EPSILON_THUMB_NORMAL or EPSILON_THUMB_LARGE
+ @parm thumb_size: one of EPSILON_THUMB_NORMAL, EPSILON_THUMB_LARGE
-+ or EPSILON_THUMB_CANOLA
@parm key: just used by edje to specify the part to process.
@parm resolution: just used by edje to specify render size.
"""
-@@ -113,9 +115,10 @@ cdef class Epsilon:
- """Specify thumbnail size, either EPSILON_THUMB_NORMAL (128x128) or
+@@ -114,7 +114,7 @@ cdef class Epsilon:
EPSILON_THUMB_LARGE (256x256).
"""
-- if value != EPSILON_THUMB_NORMAL and value != EPSILON_THUMB_LARGE:
+ if value != EPSILON_THUMB_NORMAL and value != EPSILON_THUMB_LARGE:
- raise ValueError("value must be either EPSILON_THUMB_NORMAL or "
-- "EPSILON_THUMB_LARGE")
-+ if value != EPSILON_THUMB_NORMAL and value != EPSILON_THUMB_LARGE and \
-+ value != EPSILON_THUMB_CANOLA:
+ raise ValueError("value must be either EPSILON_THUMB_NORMAL, "
-+ "EPSILON_THUMB_LARGE or EPSILON_THUMB_CANOLA")
+ "EPSILON_THUMB_LARGE")
epsilon_thumb_size(self.obj, value)
- def thumb_size_get(self):
-@@ -123,6 +126,8 @@ cdef class Epsilon:
- if self.obj:
- if self.obj.tw == EPSILON_THUMB_NORMAL:
- return EPSILON_THUMB_NORMAL
-+ elif self.obj.tw == EPSILON_THUMB_CANOLA:
-+ return EPSILON_THUMB_CANOLA
- else:
- return EPSILON_THUMB_LARGE
+@@ -133,6 +133,13 @@ cdef class Epsilon:
+ def __get__(self):
+ return self.thumb_size_get()
-diff -upr python-epsilon.orig/epsilon/epsilon.request.pyx python-epsilon/epsilon/epsilon.request.pyx
---- python-epsilon.orig/epsilon/epsilon.request.pyx 2007-11-24 22:50:53.000000000 -0300
-+++ python-epsilon/epsilon/epsilon.request.pyx 2007-12-10 18:06:21.000000000 -0300
++ def thumb_custom_size_set(self, int w, int h, char *dir):
++ """Specify a custom thumbnail size.
++ """
++ if w <= 0 and h <= 0:
++ raise ValueError("either dimension value must be positive.")
++ epsilon_custom_thumb_size(self.obj, w, h, dir)
++
+ def file_get(self):
+ "@rtype: str"
+ cdef char *s
+diff --git a/epsilon/epsilon.request.pyx b/epsilon/epsilon.request.pyx
+index c9a9fad..eea60da 100644
+--- a/epsilon/epsilon.request.pyx
++++ b/epsilon/epsilon.request.pyx
@@ -13,6 +13,7 @@ def init():
EPSILON_THUMB_NORMAL = 0
if self.obj == NULL:
self.func = func
-diff -upr python-epsilon.orig/epsilon/__init__.py python-epsilon/epsilon/__init__.py
---- python-epsilon.orig/epsilon/__init__.py 2007-11-01 15:46:42.000000000 -0300
-+++ python-epsilon/epsilon/__init__.py 2007-12-10 18:06:21.000000000 -0300
-@@ -1,3 +1,3 @@
- #!/usr/bin/env python
+diff --git a/include/epsilon/c_epsilon.pxd b/include/epsilon/c_epsilon.pxd
+index 6c4a44a..1838d7f 100644
+--- a/include/epsilon/c_epsilon.pxd
++++ b/include/epsilon/c_epsilon.pxd
+@@ -40,6 +40,7 @@ cdef extern from "Epsilon.h":
+ int epsilon_exists(_Epsilon *e)
+ int epsilon_generate(_Epsilon *e)
+ void epsilon_thumb_size(_Epsilon *e, int size)
++ void epsilon_custom_thumb_size(_Epsilon *e, int w, int h, char *dir)
+
+ _Epsilon_Info *epsilon_info_get (_Epsilon *e)
--from c_epsilon import init, EPSILON_THUMB_NORMAL, EPSILON_THUMB_LARGE, Epsilon
-+from c_epsilon import init, EPSILON_THUMB_NORMAL, EPSILON_THUMB_LARGE, EPSILON_THUMB_CANOLA, Epsilon
+--
+1.5.4.3
+