[gnome-photos/wip/rishi/thumbnailer: 10/16] Add some thumbnailing related utilities
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 10/16] Add some thumbnailing related utilities
- Date: Mon, 13 Feb 2017 22:41:58 +0000 (UTC)
commit 562ac9c426a663a6b2c0a9c65f96f96b4917a3e3
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Feb 13 18:43:39 2017 +0100
Add some thumbnailing related utilities
src/photos-thumbnail.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
src/photos-thumbnail.h | 32 ++++++++++++++++++++++++
2 files changed, 94 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-thumbnail.c b/src/photos-thumbnail.c
new file mode 100644
index 0000000..a86f229
--- /dev/null
+++ b/src/photos-thumbnail.c
@@ -0,0 +1,62 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include "photos-thumbnail.h"
+
+
+enum
+{
+ THUMBNAIL_GENERATION = 0
+};
+
+
+gchar *
+photos_thumbnail_get_path_for_file (GFile *file, gint size)
+{
+ const gchar *cache_dir;
+ gchar *filename = NULL;
+ gchar *md5 = NULL;
+ gchar *path;
+ gchar *uri = NULL;
+ gchar *thumbnails_subdir = NULL;
+
+ uri = g_file_get_uri (file);
+ md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
+ filename = g_strconcat (md5, ".png", NULL);
+
+ cache_dir = g_get_user_cache_dir ();
+ thumbnails_subdir = g_strdup_printf ("%d-%d", size, THUMBNAIL_GENERATION);
+
+ path = g_build_filename (cache_dir,
+ PACKAGE_TARNAME,
+ "thumbnails",
+ thumbnails_subdir,
+ filename,
+ NULL);
+
+ g_free (filename);
+ g_free (md5);
+ g_free (thumbnails_subdir);
+ g_free (uri);
+ return path;
+}
diff --git a/src/photos-thumbnail.h b/src/photos-thumbnail.h
new file mode 100644
index 0000000..53f6285
--- /dev/null
+++ b/src/photos-thumbnail.h
@@ -0,0 +1,32 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_THUMBNAIL_H
+#define PHOTOS_THUMBNAIL_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+gchar *photos_thumbnail_get_path_for_file (GFile *file, gint size);
+
+G_END_DECLS
+
+#endif /* PHOTOS_THUMBNAIL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]