[Xfce4-commits] <tumbler:master> Use Imdb to scale the pixbufs.
Nick Schermer
noreply at xfce.org
Thu Dec 27 11:30:07 CET 2012
Updating branch refs/heads/master
to 1b4ed876beb42b3b84b850ce20f085056b7f754c (commit)
from 2089c09dacd9ea555948ae03b63675d2b986a7e3 (commit)
commit 1b4ed876beb42b3b84b850ce20f085056b7f754c
Author: Nick Schermer <nick at xfce.org>
Date: Wed Dec 12 19:43:27 2012 +0100
Use Imdb to scale the pixbufs.
Imdb poster url can be adapted to get the correct destination
size, which is nice. It saves for download size and a resize.
plugins/cover-thumbnailer/cover-thumbnailer.c | 26 +++++++++++++++++++-----
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/plugins/cover-thumbnailer/cover-thumbnailer.c b/plugins/cover-thumbnailer/cover-thumbnailer.c
index 584b4c9..39a01b8 100644
--- a/plugins/cover-thumbnailer/cover-thumbnailer.c
+++ b/plugins/cover-thumbnailer/cover-thumbnailer.c
@@ -612,7 +612,7 @@ cover_thumbnailer_poster_url (CoverThumbnailer *cover,
gchar *url_part;
gchar *url = NULL;
gchar *data;
- gint dest_width;
+ gint dest_size;
g_return_val_if_fail (TUMBLER_IS_THUMBNAIL_FLAVOR (flavor), NULL);
g_return_val_if_fail (IS_COVER_THUMBNAILER (cover), NULL);
@@ -647,19 +647,33 @@ cover_thumbnailer_poster_url (CoverThumbnailer *cover,
if (p != NULL && k != NULL)
{
- /* extract poster data from the contents and build a working uri */
+ /* extract poster data from the contents */
url_part = g_strndup (p, k - p);
+
+ /* get destination size */
+ tumbler_thumbnail_flavor_get_size (flavor, &dest_size, NULL);
+
if (cover->api_key == NULL)
{
- /* imdb image location */
- url = g_strconcat ("http://", url_part, ".jpg", NULL);
+ if (g_str_has_suffix (url_part, "_V1_SX300"))
+ {
+ /* imdb supports output sizes, above means image X is 300px
+ * so set something that avoids scaling. Y is most of the time
+ * higher with posters, so set Y<thumbsize> */
+ url_part[strlen (url_part) - 4] = '\0';
+ url = g_strdup_printf ("http://%sY%d.jpg", url_part, dest_size);
+ }
+ else
+ {
+ /* fallback that always works */
+ url = g_strconcat ("http://", url_part, ".jpg", NULL);
+ }
}
else
{
/* see http://api.themoviedb.org/3/configuration?api_key= for the values */
- tumbler_thumbnail_flavor_get_size (flavor, &dest_width, NULL);
url = g_strconcat (TMDB_BASE_URL,
- dest_width <= 154 ? "w154" : "w342", /* optimize for 128 or 256 */
+ dest_size <= 154 ? "w154" : "w342", /* optimize for 128 or 256 */
"/", url_part, ".jpg", NULL);
}
g_free (url_part);
More information about the Xfce4-commits
mailing list