[gnome-photos] Add Instagram Clarendon
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Add Instagram Clarendon
- Date: Mon, 25 May 2020 22:52:06 +0000 (UTC)
commit bbc0c43f778a0af066024d0bdba49e65e8dc6f9c
Author: Samuel Zachara <zachara samuel gmail com>
Date: Tue May 19 17:46:25 2020 +0200
Add Instagram Clarendon
Analysis: https://rishi.fedorapeople.org/instagram/clarendon/
https://gitlab.gnome.org/GNOME/gnome-photos/-/merge_requests/129
src/meson.build | 1 +
src/photos-gegl.c | 2 +
src/photos-operation-insta-clarendon.c | 134 +++++++++++++++++++++
src/photos-operation-insta-clarendon.h | 35 ++++++
src/photos-operation-insta-common.h | 2 +
src/photos-operation-insta-curve.c | 1 +
src/photos-operation-insta-filter.c | 7 ++
src/photos-tool-filters.c | 16 ++-
tests/unit/meson.build | 2 +
...test-pipeline-edited-insta-filter-clarendon.xml | 8 ++
...s-test-pipeline-edited-magic-filter-trencin.xml | 8 ++
tests/unit/photos-test-pipeline.c | 58 +++++++++
12 files changed, 269 insertions(+), 5 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 1b29d045..9919f0cf 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -6,6 +6,7 @@ sources = files(
'photos-gegl.c',
'photos-glib.c',
'photos-jpeg-count.c',
+ 'photos-operation-insta-clarendon.c',
'photos-operation-insta-curve.c',
'photos-operation-insta-filter.c',
'photos-operation-insta-hefe.c',
diff --git a/src/photos-gegl.c b/src/photos-gegl.c
index b793360b..c2e12af3 100644
--- a/src/photos-gegl.c
+++ b/src/photos-gegl.c
@@ -25,6 +25,7 @@
#include "photos-debug.h"
#include "photos-gegl.h"
+#include "photos-operation-insta-clarendon.h"
#include "photos-operation-insta-curve.h"
#include "photos-operation-insta-filter.h"
#include "photos-operation-insta-hefe.h"
@@ -631,6 +632,7 @@ photos_gegl_ensure_builtins (void)
if (g_once_init_enter (&once_init_value))
{
+ g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_CLARENDON);
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_CURVE);
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_FILTER);
g_type_ensure (PHOTOS_TYPE_OPERATION_INSTA_HEFE);
diff --git a/src/photos-operation-insta-clarendon.c b/src/photos-operation-insta-clarendon.c
new file mode 100644
index 00000000..f53d486b
--- /dev/null
+++ b/src/photos-operation-insta-clarendon.c
@@ -0,0 +1,134 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2020 Samuel Zachara
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "config.h"
+
+#include <math.h>
+
+#include <babl/babl.h>
+#include <gegl.h>
+
+#include "photos-operation-insta-clarendon.h"
+
+
+struct _PhotosOperationInstaClarendon
+{
+ GeglOperationPointFilter parent_instance;
+};
+
+
+G_DEFINE_TYPE (PhotosOperationInstaClarendon, photos_operation_insta_clarendon,
GEGL_TYPE_OPERATION_POINT_FILTER);
+
+
+static void
+photos_operation_insta_clarendon_prepare (GeglOperation *operation)
+{
+ const Babl *format;
+
+ format = babl_format ("R'G'B' u8");
+ gegl_operation_set_format (operation, "input", format);
+ gegl_operation_set_format (operation, "output", format);
+}
+
+
+static gboolean
+photos_operation_insta_clarendon_process (GeglOperation *operation,
+ void *in_buf,
+ void *out_buf,
+ glong n_pixels,
+ const GeglRectangle *roi,
+ gint level)
+{
+ guint8 *in = in_buf;
+ guint8 *out = out_buf;
+ glong i;
+
+ for (i = 0; i < n_pixels; i++)
+ {
+
+ const guint32 b = (guint32) in[2];
+ const guint32 b2 = b * b;
+ const guint32 b3 = b2 * b;
+ const guint32 b4 = b3 * b;
+ const guint32 g = (guint32) in[1];
+ const guint32 g2 = g * g;
+ const guint32 g3 = g2 * g;
+ const guint32 g4 = g3 * g;
+ const guint32 r = (guint32) in[0];
+ const guint32 r2 = r * r;
+ const guint32 r3 = r2 * r;
+ const guint32 r4 = r3 * r;
+
+ gint32 r_out = 18.37f
+ - 1.05f * r
+ - 0.0276f * g
+ + 0.03275f * r2
+ - 0.001056f * r * g
+ - 0.000152f * r3
+ + 2.006e-6f * r2 * g
+ + 2.091e-7f * r4
+ + 9.682e-9f * r3 * g;
+
+ gint32 g_out = 6.87f - 0.1453 * g + 0.02435 * g2 - 0.0001355 * g3 + 2.267e-7 * g4;
+
+ gint32 b_out = 13.3f
+ + 0.4149f * b
+ - 0.08369f * g
+ + 0.01699f * b2
+ - 0.001413f * b * g
+ - 9.235e-5f * b3
+ + 1.239e-5f *b2 * g
+ + 1.334e-7f * b4
+ - 2.221e-8f * b3 * g;
+
+ out[0] = (guint8) CLAMP(r_out, 0, 255);
+ out[1] = (guint8) CLAMP(g_out, 0, 255);
+ out[2] = (guint8) CLAMP(b_out, 0, 255);
+
+ in += 3;
+ out += 3;
+ }
+ return TRUE;
+}
+
+
+static void
+photos_operation_insta_clarendon_init (PhotosOperationInstaClarendon *self)
+{
+}
+
+
+static void
+photos_operation_insta_clarendon_class_init (PhotosOperationInstaClarendonClass *class)
+{
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (class);
+ GeglOperationPointFilterClass *point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (class);
+
+ operation_class->opencl_support = FALSE;
+
+ operation_class->prepare = photos_operation_insta_clarendon_prepare;
+ point_filter_class->process = photos_operation_insta_clarendon_process;
+
+ gegl_operation_class_set_keys (operation_class,
+ "name", "photos:insta-clarendon",
+ "title", "Insta Clarendon",
+ "description", "Apply the Clarendon filter to an image",
+ "categories", "hidden",
+ NULL);
+}
diff --git a/src/photos-operation-insta-clarendon.h b/src/photos-operation-insta-clarendon.h
new file mode 100644
index 00000000..ae692f21
--- /dev/null
+++ b/src/photos-operation-insta-clarendon.h
@@ -0,0 +1,35 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2020 Samuel Zachara
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PHOTOS_OPERATION_INSTA_CLARENDON_H
+#define PHOTOS_OPERATION_INSTA_CLARENDON_H
+
+#include <gegl-plugin.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_OPERATION_INSTA_CLARENDON (photos_operation_insta_clarendon_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosOperationInstaClarendon,
+ photos_operation_insta_clarendon,
+ PHOTOS,
+ OPERATION_INSTA_CLARENDON,
+ GeglOperationPointFilter);
+
+G_END_DECLS
+
+#endif /* PHOTOS_OPERATION_INSTA_CLARENDON_H */
diff --git a/src/photos-operation-insta-common.h b/src/photos-operation-insta-common.h
index 5c90bd51..a86b69a4 100644
--- a/src/photos-operation-insta-common.h
+++ b/src/photos-operation-insta-common.h
@@ -26,12 +26,14 @@ typedef enum
PHOTOS_OPERATION_INSTA_PRESET_NONE,
PHOTOS_OPERATION_INSTA_PRESET_1947,
PHOTOS_OPERATION_INSTA_PRESET_CALISTOGA,
+ PHOTOS_OPERATION_INSTA_PRESET_TRENCIN,
PHOTOS_OPERATION_INSTA_PRESET_CAAP,
PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU,
PHOTOS_OPERATION_INSTA_PRESET_HOMETOWN,
PHOTOS_OPERATION_INSTA_PRESET_1977 = PHOTOS_OPERATION_INSTA_PRESET_1947,
PHOTOS_OPERATION_INSTA_PRESET_BRANNAN = PHOTOS_OPERATION_INSTA_PRESET_CALISTOGA,
+ PHOTOS_OPERATION_INSTA_PRESET_CLARENDON = PHOTOS_OPERATION_INSTA_PRESET_TRENCIN,
PHOTOS_OPERATION_INSTA_PRESET_HEFE = PHOTOS_OPERATION_INSTA_PRESET_CAAP,
PHOTOS_OPERATION_INSTA_PRESET_GOTHAM = PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU,
PHOTOS_OPERATION_INSTA_PRESET_NASHVILLE = PHOTOS_OPERATION_INSTA_PRESET_HOMETOWN,
diff --git a/src/photos-operation-insta-curve.c b/src/photos-operation-insta-curve.c
index 3a86f863..fc62919f 100644
--- a/src/photos-operation-insta-curve.c
+++ b/src/photos-operation-insta-curve.c
@@ -1013,6 +1013,7 @@ photos_operation_insta_curve_prepare (GeglOperation *operation)
case PHOTOS_OPERATION_INSTA_PRESET_NONE:
case PHOTOS_OPERATION_INSTA_PRESET_HEFE:
+ case PHOTOS_OPERATION_INSTA_PRESET_CLARENDON:
default:
g_assert_not_reached ();
}
diff --git a/src/photos-operation-insta-filter.c b/src/photos-operation-insta-filter.c
index 7b9aecf7..52a1f91f 100644
--- a/src/photos-operation-insta-filter.c
+++ b/src/photos-operation-insta-filter.c
@@ -82,6 +82,13 @@ photos_operation_insta_filter_setup (PhotosOperationInstaFilter *self)
self->nodes = g_list_prepend (self->nodes, node);
break;
+ case PHOTOS_OPERATION_INSTA_PRESET_CLARENDON:
+ node = gegl_node_new_child (operation->node,
+ "operation", "photos:insta-clarendon",
+ NULL);
+ self->nodes = g_list_prepend (self->nodes, node);
+ break;
+
case PHOTOS_OPERATION_INSTA_PRESET_GOTHAM:
node = gegl_node_new_child (operation->node,
"operation", "photos:insta-curve",
diff --git a/src/photos-tool-filters.c b/src/photos-tool-filters.c
index fb5b7497..6c195ff4 100644
--- a/src/photos-tool-filters.c
+++ b/src/photos-tool-filters.c
@@ -199,25 +199,31 @@ photos_tool_filters_init (PhotosToolFilters *self)
gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
- button = photos_tool_filter_button_new (group, _("Mogadishu"));
+ button = photos_tool_filter_button_new (group, _("Trencin"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
- gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16)
PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU);
+ gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16)
PHOTOS_OPERATION_INSTA_PRESET_TRENCIN);
gtk_grid_attach (GTK_GRID (self->grid), button, 1, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
row++;
+ button = photos_tool_filter_button_new (group, _("Mogadishu"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
+ gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16)
PHOTOS_OPERATION_INSTA_PRESET_MOGADISHU);
+ gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
+ self->buttons = g_list_prepend (self->buttons, button);
+
button = photos_tool_filter_button_new (group, _("Caap"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16)
PHOTOS_OPERATION_INSTA_PRESET_CAAP);
- gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (self->grid), button, 1, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
+ row++;
button = photos_tool_filter_button_new (group, _("Hometown"));
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.insta-current");
gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "n", (gint16)
PHOTOS_OPERATION_INSTA_PRESET_HOMETOWN);
- gtk_grid_attach (GTK_GRID (self->grid), button, 1, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (self->grid), button, 0, row, 1, 1);
self->buttons = g_list_prepend (self->buttons, button);
- row++;
self->buttons = g_list_reverse (self->buttons);
}
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index e8ebc82a..625ca598 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -25,12 +25,14 @@ test_data = [
'photos-test-pipeline-edited-insta-filter-none.xml',
'photos-test-pipeline-edited-insta-filter-1977.xml',
'photos-test-pipeline-edited-insta-filter-brannan.xml',
+ 'photos-test-pipeline-edited-insta-filter-clarendon.xml',
'photos-test-pipeline-edited-insta-filter-gotham.xml',
'photos-test-pipeline-edited-insta-filter-hefe.xml',
'photos-test-pipeline-edited-insta-filter-nashville.xml',
'photos-test-pipeline-edited-magic-filter-none.xml',
'photos-test-pipeline-edited-magic-filter-1947.xml',
'photos-test-pipeline-edited-magic-filter-calistoga.xml',
+ 'photos-test-pipeline-edited-insta-filter-trencin.xml',
'photos-test-pipeline-edited-magic-filter-caap.xml',
'photos-test-pipeline-edited-magic-filter-mogadishu.xml',
'photos-test-pipeline-edited-magic-filter-hometown.xml',
diff --git a/tests/unit/photos-test-pipeline-edited-insta-filter-clarendon.xml
b/tests/unit/photos-test-pipeline-edited-insta-filter-clarendon.xml
new file mode 100644
index 00000000..f08033a2
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-insta-filter-clarendon.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:insta-filter'>
+ <params>
+ <param name='preset'>clarendon</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-trencin.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-trencin.xml
new file mode 100644
index 00000000..0084b879
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-trencin.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>trencin</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline.c b/tests/unit/photos-test-pipeline.c
index f8c244d2..8e45132e 100644
--- a/tests/unit/photos-test-pipeline.c
+++ b/tests/unit/photos-test-pipeline.c
@@ -352,6 +352,28 @@ photos_test_pipeline_insta_filter_brannan (PhotosTestPipelineFixture *fixture, g
}
+static void
+photos_test_pipeline_insta_filter_clarendon (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+ g_autoptr (PhotosPipeline) pipeline = NULL;
+ const gchar *const filenames[] = { "photos-test-pipeline-edited-insta-filter-clarendon.xml", NULL };
+
+ photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
+ g_main_loop_run (fixture->loop);
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ pipeline = photos_pipeline_new_finish (fixture->res, &error);
+ g_assert_no_error (error);
+ }
+
+ photos_test_pipeline_check_insta_filter (pipeline,
+ PHOTOS_OPERATION_INSTA_PRESET_CLARENDON,
+ PHOTOS_OPERATION_INSTA_PRESET_TRENCIN);
+}
+
+
static void
photos_test_pipeline_insta_filter_gotham (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
@@ -484,6 +506,28 @@ photos_test_pipeline_magic_filter_calistoga (PhotosTestPipelineFixture *fixture,
}
+static void
+photos_test_pipeline_magic_filter_trencin (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+ g_autoptr (PhotosPipeline) pipeline = NULL;
+ const gchar *const filenames[] = { "photos-test-pipeline-edited-magic-filter-trencin.xml", NULL };
+
+ photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
+ g_main_loop_run (fixture->loop);
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ pipeline = photos_pipeline_new_finish (fixture->res, &error);
+ g_assert_no_error (error);
+ }
+
+ photos_test_pipeline_check_insta_filter (pipeline,
+ PHOTOS_OPERATION_INSTA_PRESET_TRENCIN,
+ PHOTOS_OPERATION_INSTA_PRESET_CLARENDON);
+}
+
+
static void
photos_test_pipeline_magic_filter_mogadishu (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
@@ -1817,6 +1861,13 @@ main (gint argc, gchar *argv[])
photos_test_pipeline_insta_filter_brannan,
photos_test_pipeline_teardown);
+ g_test_add ("/pipeline/new/insta-filter-clarendon",
+ PhotosTestPipelineFixture,
+ NULL,
+ photos_test_pipeline_setup,
+ photos_test_pipeline_insta_filter_clarendon,
+ photos_test_pipeline_teardown);
+
g_test_add ("/pipeline/new/insta-filter-gotham",
PhotosTestPipelineFixture,
NULL,
@@ -1859,6 +1910,13 @@ main (gint argc, gchar *argv[])
photos_test_pipeline_magic_filter_calistoga,
photos_test_pipeline_teardown);
+ g_test_add ("/pipeline/new/magic-filter-trencin",
+ PhotosTestPipelineFixture,
+ NULL,
+ photos_test_pipeline_setup,
+ photos_test_pipeline_magic_filter_trencin,
+ photos_test_pipeline_teardown);
+
g_test_add ("/pipeline/new/magic-filter-mogadishu",
PhotosTestPipelineFixture,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]