Initial checkin of Pika from heckimp
This commit is contained in:
88
plug-ins/file-raw/file-darktable-export-on-exit.lua
Normal file
88
plug-ins/file-raw/file-darktable-export-on-exit.lua
Normal file
@ -0,0 +1,88 @@
|
||||
--[[
|
||||
This file is part of PIKA,
|
||||
copyright (c) 2015-2017 Tobias Ellinghaus
|
||||
|
||||
PIKA 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.
|
||||
|
||||
PIKA 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 PIKA. If not, see <https://www.gnu.org/licenses/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
EXPORT ON EXIT
|
||||
exports all (but at most 1) images from the database to prefs setting "lua/export_on_exit/export_filename"
|
||||
when darktable exits
|
||||
|
||||
|
||||
USAGE
|
||||
* require this file from your main lua config file
|
||||
* or: use --luacmd "dofile('/path/to/this/file.lua')"
|
||||
* and make sure to set the export filename
|
||||
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
local orig_register_event = dt.register_event
|
||||
|
||||
function dt.register_event(name, event, func, label)
|
||||
if dt.configuration.api_version_string >= "6.2.1" then
|
||||
if label then
|
||||
orig_register_event(name, event, func, label)
|
||||
else
|
||||
orig_register_event(name, event, func)
|
||||
end
|
||||
else
|
||||
if label then
|
||||
orig_register_event(event, func, label)
|
||||
else
|
||||
orig_register_event(event, func)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local min_api_version = "2.1.0"
|
||||
if dt.configuration.api_version_string < min_api_version then
|
||||
dt.print("the exit export script requires at least darktable version 1.7.0")
|
||||
dt.print_error("the exit export script requires at least darktable version 1.7.0")
|
||||
return
|
||||
else
|
||||
dt.print("closing darktable will export the image and make PIKA load it")
|
||||
end
|
||||
|
||||
local CURR_API_STRING = dt.configuration.api_version_string
|
||||
|
||||
local export_filename = dt.preferences.read("export_on_exit", "export_filename", "string")
|
||||
|
||||
dt.register_event("fileraw", "exit", function()
|
||||
-- safegurad against someone using this with their library containing 50k images
|
||||
if #dt.database > 1 then
|
||||
dt.print_error("too many images, only exporting the first")
|
||||
-- return
|
||||
end
|
||||
|
||||
-- change the view first to force writing of the history stack
|
||||
dt.gui.current_view(dt.gui.views.lighttable)
|
||||
-- now export
|
||||
local format = dt.new_format("exr")
|
||||
format.max_width = 0
|
||||
format.max_height = 0
|
||||
-- let's have the export in a loop so we could easily support > 1 images
|
||||
for _, image in ipairs(dt.database) do
|
||||
dt.print_error("exporting `"..tostring(image).."' to `"..export_filename.."'")
|
||||
format:write_image(image, export_filename)
|
||||
break -- only export one image. see above for the reason
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
-- kate: hl Lua;
|
21
plug-ins/file-raw/file-darktable-get-size.lua
Normal file
21
plug-ins/file-raw/file-darktable-get-size.lua
Normal file
@ -0,0 +1,21 @@
|
||||
--[[
|
||||
This file is part of PIKA,
|
||||
copyright (c) 2016 Tobias Ellinghaus
|
||||
|
||||
PIKA 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.
|
||||
|
||||
PIKA 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 PIKA. If not, see <https://www.gnu.org/licenses/>.
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
print("[dt4pika] " .. (dt.database[1].width) .. " " .. (dt.database[1].height))
|
559
plug-ins/file-raw/file-darktable.c
Normal file
559
plug-ins/file-raw/file-darktable.c
Normal file
@ -0,0 +1,559 @@
|
||||
/* PIKA - Photo and Image Kooker Application
|
||||
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
||||
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
||||
*
|
||||
* Original copyright, applying to most contents (license remains unchanged):
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* file-darktable.c -- raw file format plug-in that uses darktable
|
||||
* Copyright (C) 2012 Simon Budig <simon@gimp.org>
|
||||
* Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <libpika/pika.h>
|
||||
|
||||
#include "libpika/stdplugins-intl.h"
|
||||
|
||||
#include "file-raw-formats.h"
|
||||
#include "file-raw-utils.h"
|
||||
|
||||
|
||||
#define LOAD_THUMB_PROC "file-darktable-load-thumb"
|
||||
#define REGISTRY_KEY_BASE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable"
|
||||
|
||||
|
||||
typedef struct _Darktable Darktable;
|
||||
typedef struct _DarktableClass DarktableClass;
|
||||
|
||||
struct _Darktable
|
||||
{
|
||||
PikaPlugIn parent_instance;
|
||||
};
|
||||
|
||||
struct _DarktableClass
|
||||
{
|
||||
PikaPlugInClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
#define DARKTABLE_TYPE (darktable_get_type ())
|
||||
#define DARKTABLE (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DARKTABLE_TYPE, Darktable))
|
||||
|
||||
GType darktable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
static GList * darktable_init_procedures (PikaPlugIn *plug_in);
|
||||
static PikaProcedure * darktable_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
static PikaValueArray * darktable_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
static PikaValueArray * darktable_load_thumb (PikaProcedure *procedure,
|
||||
GFile *file,
|
||||
gint size,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
|
||||
static PikaImage * load_image (GFile *file,
|
||||
PikaRunMode run_mode,
|
||||
GError **error);
|
||||
static PikaImage * load_thumbnail_image (GFile *file,
|
||||
gint thumb_size,
|
||||
gint *width,
|
||||
gint *height,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (Darktable, darktable, PIKA_TYPE_PLUG_IN)
|
||||
|
||||
PIKA_MAIN (DARKTABLE_TYPE)
|
||||
DEFINE_STD_SET_I18N
|
||||
|
||||
|
||||
static void
|
||||
darktable_class_init (DarktableClass *klass)
|
||||
{
|
||||
PikaPlugInClass *plug_in_class = PIKA_PLUG_IN_CLASS (klass);
|
||||
|
||||
plug_in_class->init_procedures = darktable_init_procedures;
|
||||
plug_in_class->create_procedure = darktable_create_procedure;
|
||||
plug_in_class->set_i18n = STD_SET_I18N;
|
||||
}
|
||||
|
||||
static void
|
||||
darktable_init (Darktable *darktable)
|
||||
{
|
||||
}
|
||||
|
||||
static GList *
|
||||
darktable_init_procedures (PikaPlugIn *plug_in)
|
||||
{
|
||||
/* check if darktable is installed
|
||||
*/
|
||||
gboolean search_path = FALSE;
|
||||
gchar *exec_path = file_raw_get_executable_path ("darktable", NULL,
|
||||
"DARKTABLE_EXECUTABLE",
|
||||
"org.darktable",
|
||||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
gchar *argv[] = { exec_path, "--version", NULL };
|
||||
gchar *darktable_stdout = NULL;
|
||||
gchar *darktable_stderr = NULL;
|
||||
gboolean have_darktable = FALSE;
|
||||
GError *error = NULL;
|
||||
gint i;
|
||||
|
||||
/* allow the user to have some insight into why darktable may fail. */
|
||||
gboolean debug_prints = g_getenv ("DARKTABLE_DEBUG") != NULL;
|
||||
|
||||
if (debug_prints)
|
||||
g_printf ("[%s] trying to call '%s'\n", __FILE__, exec_path);
|
||||
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0),
|
||||
NULL,
|
||||
NULL,
|
||||
&darktable_stdout,
|
||||
&darktable_stderr,
|
||||
NULL,
|
||||
&error))
|
||||
{
|
||||
GRegex *regex;
|
||||
GMatchInfo *matches;
|
||||
gint major;
|
||||
gint minor;
|
||||
|
||||
/* A default darktable would apparently output something like
|
||||
* "this is darktable 2.2.5", but this version string is
|
||||
* customizable. In the official Fedora package for instance, I
|
||||
* encountered a "this is darktable darktable-2.2.5-4.fc27".
|
||||
* Therefore make the version recognition a bit more flexible.
|
||||
*/
|
||||
regex = g_regex_new ("this is darktable [^0-9]*([0-9]+)\\.([0-9]+)\\.([0-9]+)",
|
||||
0, 0, NULL);
|
||||
if (g_regex_match (regex, darktable_stdout, 0, &matches))
|
||||
{
|
||||
gchar *match;
|
||||
|
||||
match = g_match_info_fetch (matches, 1);
|
||||
major = g_ascii_strtoll (match, NULL, 10);
|
||||
g_free (match);
|
||||
|
||||
match = g_match_info_fetch (matches, 2);
|
||||
minor = g_ascii_strtoll (match, NULL, 10);
|
||||
g_free (match);
|
||||
|
||||
if (((major == 1 && minor >= 7) || major >= 2))
|
||||
{
|
||||
if (g_strstr_len (darktable_stdout, -1,
|
||||
"Lua support enabled"))
|
||||
{
|
||||
have_darktable = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_match_info_free (matches);
|
||||
g_regex_unref (regex);
|
||||
}
|
||||
else if (debug_prints)
|
||||
{
|
||||
g_printf ("[%s] g_spawn_sync failed\n", __FILE__);
|
||||
}
|
||||
|
||||
if (debug_prints)
|
||||
{
|
||||
if (error)
|
||||
g_printf ("[%s] error: %s\n", __FILE__, error->message);
|
||||
|
||||
if (darktable_stdout && *darktable_stdout)
|
||||
g_printf ("[%s] stdout:\n%s\n", __FILE__, darktable_stdout);
|
||||
|
||||
if (darktable_stderr && *darktable_stderr)
|
||||
g_printf ("[%s] stderr:\n%s\n", __FILE__, darktable_stderr);
|
||||
|
||||
g_printf ("[%s] have_darktable: %d\n", __FILE__, have_darktable);
|
||||
}
|
||||
|
||||
g_clear_error (&error);
|
||||
|
||||
g_free (darktable_stdout);
|
||||
g_free (darktable_stderr);
|
||||
g_free (exec_path);
|
||||
|
||||
if (have_darktable)
|
||||
{
|
||||
GList *list = NULL;
|
||||
|
||||
list = g_list_append (list, g_strdup (LOAD_THUMB_PROC));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
|
||||
{
|
||||
const FileFormat *format = &file_formats[i];
|
||||
gchar *load_proc;
|
||||
|
||||
load_proc = g_strdup_printf (format->load_proc_format, "darktable");
|
||||
|
||||
list = g_list_append (list, load_proc);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PikaProcedure *
|
||||
darktable_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
PikaProcedure *procedure = NULL;
|
||||
|
||||
if (! strcmp (name, LOAD_THUMB_PROC))
|
||||
{
|
||||
procedure = pika_thumbnail_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
darktable_load_thumb, NULL, NULL);
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
"Load thumbnail from a raw image "
|
||||
"via darktable",
|
||||
"This plug-in loads a thumbnail "
|
||||
"from a raw image by calling "
|
||||
"darktable-cli.",
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Tobias Ellinghaus",
|
||||
"Tobias Ellinghaus",
|
||||
"2016");
|
||||
}
|
||||
else
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
|
||||
{
|
||||
const FileFormat *format = &file_formats[i];
|
||||
gchar *load_proc;
|
||||
gchar *load_blurb;
|
||||
gchar *load_help;
|
||||
|
||||
load_proc = g_strdup_printf (format->load_proc_format, "darktable");
|
||||
|
||||
if (strcmp (name, load_proc))
|
||||
{
|
||||
g_free (load_proc);
|
||||
continue;
|
||||
}
|
||||
|
||||
load_blurb = g_strdup_printf (format->load_blurb_format, "darktable");
|
||||
load_help = g_strdup_printf (format->load_help_format, "darktable");
|
||||
|
||||
procedure = pika_load_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
darktable_load,
|
||||
(gpointer) format, NULL);
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
load_blurb, load_help, name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Tobias Ellinghaus",
|
||||
"Tobias Ellinghaus",
|
||||
"2016");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->mime_type);
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->extensions);
|
||||
pika_file_procedure_set_magics (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->magic);
|
||||
|
||||
pika_load_procedure_set_handles_raw (PIKA_LOAD_PROCEDURE (procedure),
|
||||
TRUE);
|
||||
pika_load_procedure_set_thumbnail_loader (PIKA_LOAD_PROCEDURE (procedure),
|
||||
LOAD_THUMB_PROC);
|
||||
|
||||
g_free (load_proc);
|
||||
g_free (load_blurb);
|
||||
g_free (load_help);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
darktable_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaValueArray *return_vals;
|
||||
PikaImage *image;
|
||||
GError *error = NULL;
|
||||
|
||||
image = load_image (file, run_mode, &error);
|
||||
|
||||
if (! image)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
|
||||
return_vals = pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
PIKA_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
darktable_load_thumb (PikaProcedure *procedure,
|
||||
GFile *file,
|
||||
gint size,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaValueArray *return_vals;
|
||||
gint width;
|
||||
gint height;
|
||||
PikaImage *image = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
width = size;
|
||||
height = size;
|
||||
|
||||
image = load_thumbnail_image (file, width, &width, &height, &error);
|
||||
|
||||
if (! image)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
|
||||
return_vals = pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
PIKA_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
PIKA_VALUES_SET_INT (return_vals, 2, width);
|
||||
PIKA_VALUES_SET_INT (return_vals, 3, height);
|
||||
PIKA_VALUES_SET_ENUM (return_vals, 4, PIKA_RGB_IMAGE);
|
||||
PIKA_VALUES_SET_INT (return_vals, 5, 1);
|
||||
|
||||
pika_value_array_truncate (return_vals, 6);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaImage *
|
||||
load_image (GFile *file,
|
||||
PikaRunMode run_mode,
|
||||
GError **error)
|
||||
{
|
||||
PikaImage *image = NULL;
|
||||
GFile *lua_file = pika_data_directory_file ("file-raw",
|
||||
"file-darktable-export-on-exit.lua",
|
||||
NULL);
|
||||
gchar *lua_script_escaped = g_strescape (g_file_peek_path (lua_file), "");
|
||||
gchar *lua_quoted = g_shell_quote (lua_script_escaped);
|
||||
gchar *lua_cmd = g_strdup_printf ("dofile(%s)", lua_quoted);
|
||||
GFile *file_out = pika_temp_file ("exr");
|
||||
gchar *export_filename = g_strdup_printf ("lua/export_on_exit/export_filename=%s",
|
||||
g_file_peek_path (file_out));
|
||||
|
||||
gchar *darktable_stdout = NULL;
|
||||
gchar *darktable_stderr = NULL;
|
||||
|
||||
/* allow the user to have some insight into why darktable may fail. */
|
||||
gboolean debug_prints = g_getenv ("DARKTABLE_DEBUG") != NULL;
|
||||
|
||||
/* linear sRGB for now as PIKA uses that internally in many places anyway */
|
||||
gboolean search_path = FALSE;
|
||||
gchar *exec_path = file_raw_get_executable_path ("darktable", NULL,
|
||||
"DARKTABLE_EXECUTABLE",
|
||||
"org.darktable",
|
||||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
gchar *argv[] =
|
||||
{
|
||||
exec_path,
|
||||
"--library", ":memory:",
|
||||
"--luacmd", lua_cmd,
|
||||
"--conf", "plugins/lighttable/export/icctype=3",
|
||||
"--conf", export_filename,
|
||||
(gchar *) g_file_peek_path (file),
|
||||
NULL
|
||||
};
|
||||
|
||||
g_object_unref (lua_file);
|
||||
g_free (lua_script_escaped);
|
||||
g_free (lua_quoted);
|
||||
|
||||
pika_progress_init_printf (_("Opening '%s'"),
|
||||
pika_file_get_utf8_name (file));
|
||||
|
||||
if (debug_prints)
|
||||
{
|
||||
gchar **environ_ = g_get_environ ();
|
||||
gint i;
|
||||
|
||||
g_printf ("[%s] trying to call\n", __FILE__);
|
||||
for (gchar **iter = argv; *iter; iter++)
|
||||
g_printf (" %s\n", *iter);
|
||||
g_printf ("\n");
|
||||
|
||||
g_printf ("## Environment ##\n");
|
||||
for (i = 0; environ_[i]; i++)
|
||||
g_printf ("- %s\n", environ_[i]);
|
||||
g_strfreev (environ_) ;
|
||||
}
|
||||
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
/*G_SPAWN_STDOUT_TO_DEV_NULL |*/
|
||||
/*G_SPAWN_STDERR_TO_DEV_NULL |*/
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0),
|
||||
NULL,
|
||||
NULL,
|
||||
&darktable_stdout,
|
||||
&darktable_stderr,
|
||||
NULL,
|
||||
error))
|
||||
{
|
||||
image = pika_file_load (run_mode, file_out);
|
||||
}
|
||||
|
||||
if (debug_prints)
|
||||
{
|
||||
if (darktable_stdout && *darktable_stdout)
|
||||
g_printf ("\n## stdout ##\n%s\n", darktable_stdout);
|
||||
|
||||
if (darktable_stderr && *darktable_stderr)
|
||||
g_printf ("\n## stderr ##\n%s\n", darktable_stderr);
|
||||
}
|
||||
|
||||
g_free (darktable_stdout);
|
||||
g_free (darktable_stderr);
|
||||
|
||||
g_file_delete (file_out, NULL, NULL);
|
||||
g_free (lua_cmd);
|
||||
g_free (export_filename);
|
||||
g_free (exec_path);
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static PikaImage *
|
||||
load_thumbnail_image (GFile *file,
|
||||
gint thumb_size,
|
||||
gint *width,
|
||||
gint *height,
|
||||
GError **error)
|
||||
{
|
||||
PikaImage *image = NULL;
|
||||
|
||||
GFile *file_out = pika_temp_file ("jpg");
|
||||
gchar *size = g_strdup_printf ("%d", thumb_size);
|
||||
GFile *lua_file = pika_data_directory_file ("file-raw",
|
||||
"file-darktable-get-size.lua",
|
||||
NULL);
|
||||
gchar *lua_script_escaped = g_strescape (g_file_peek_path (lua_file), "");
|
||||
gchar *lua_quoted = g_shell_quote (lua_script_escaped);
|
||||
gchar *lua_cmd = g_strdup_printf ("dofile(%s)", lua_quoted);
|
||||
gchar *darktable_stdout = NULL;
|
||||
|
||||
gboolean search_path = FALSE;
|
||||
gchar *exec_path = file_raw_get_executable_path ("darktable", "-cli",
|
||||
"DARKTABLE_EXECUTABLE",
|
||||
"org.darktable",
|
||||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
gchar *argv[] =
|
||||
{
|
||||
exec_path,
|
||||
(gchar *) g_file_peek_path (file),
|
||||
(gchar *) g_file_peek_path (file_out),
|
||||
"--width", size,
|
||||
"--height", size,
|
||||
"--hq", "false",
|
||||
"--core",
|
||||
"--conf", "plugins/lighttable/export/icctype=3",
|
||||
"--luacmd", lua_cmd,
|
||||
NULL
|
||||
};
|
||||
|
||||
g_object_unref (lua_file);
|
||||
g_free (lua_script_escaped);
|
||||
g_free (lua_quoted);
|
||||
|
||||
pika_progress_init_printf (_("Opening thumbnail for '%s'"),
|
||||
pika_file_get_utf8_name (file));
|
||||
|
||||
*width = *height = thumb_size;
|
||||
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
G_SPAWN_STDERR_TO_DEV_NULL |
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0),
|
||||
NULL,
|
||||
NULL,
|
||||
&darktable_stdout,
|
||||
NULL,
|
||||
NULL,
|
||||
error))
|
||||
{
|
||||
pika_progress_update (0.5);
|
||||
|
||||
image = pika_file_load (PIKA_RUN_NONINTERACTIVE, file_out);
|
||||
if (image)
|
||||
{
|
||||
/* the size reported by raw files isn't precise,
|
||||
* but it should be close enough to get an idea.
|
||||
*/
|
||||
gchar *start_of_size = g_strstr_len (darktable_stdout,
|
||||
-1,
|
||||
"[dt4pika]");
|
||||
if (start_of_size)
|
||||
sscanf (start_of_size, "[dt4pika] %d %d", width, height);
|
||||
}
|
||||
}
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
g_file_delete (file_out, NULL, NULL);
|
||||
g_free (size);
|
||||
g_free (lua_cmd);
|
||||
g_free (darktable_stdout);
|
||||
g_free (exec_path);
|
||||
|
||||
return image;
|
||||
}
|
324
plug-ins/file-raw/file-raw-formats.h
Normal file
324
plug-ins/file-raw/file-raw-formats.h
Normal file
@ -0,0 +1,324 @@
|
||||
/* PIKA - Photo and Image Kooker Application
|
||||
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
||||
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
||||
*
|
||||
* Original copyright, applying to most contents (license remains unchanged):
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* file-darktable.c -- raw file format plug-in that uses darktable
|
||||
* Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* These are the raw formats that file-darktable will register */
|
||||
|
||||
typedef struct _FileFormat FileFormat;
|
||||
|
||||
struct _FileFormat
|
||||
{
|
||||
const gchar *file_type;
|
||||
const gchar *mime_type;
|
||||
const gchar *extensions;
|
||||
const gchar *magic;
|
||||
|
||||
const gchar *load_proc_format;
|
||||
const gchar *load_blurb_format;
|
||||
const gchar *load_help_format;
|
||||
};
|
||||
|
||||
/* some magic numbers taken from
|
||||
* http://www.garykessler.net/library/file_sigs.html
|
||||
*
|
||||
* see also
|
||||
* http://fileformats.archiveteam.org/wiki/Cameras_and_Digital_Image_Sensors
|
||||
*/
|
||||
static const FileFormat file_formats[] =
|
||||
{
|
||||
{
|
||||
N_("Raw Canon"),
|
||||
"image/x-canon-cr2,image/x-canon-crw,image/x-canon-cr3",
|
||||
"cr2,crw,cr3",
|
||||
"0,string,II*\\0\\020\\0\\0\\0CR," /* cr2 */
|
||||
"0,string,II\\024\\0\\0\\0HEAPCCDR," /* crw */
|
||||
"4,string,ftypcrx ", /* cr3 */
|
||||
|
||||
"file-%s-canon-load",
|
||||
"Load files in the Canon raw formats via %s",
|
||||
"This plug-in loads files in Canon's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Nikon"),
|
||||
"image/x-nikon-nef,image/x-nikon-nrw",
|
||||
"nef,nrw",
|
||||
NULL,
|
||||
|
||||
"file-%s-nikon-load",
|
||||
"Load files in the Nikon raw formats via %s",
|
||||
"This plug-in loads files in Nikon's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Hasselblad"),
|
||||
"image/x-hasselblad-3fr,image/x-hasselblad-fff",
|
||||
"3fr,fff",
|
||||
NULL,
|
||||
|
||||
"file-%s-hasselblad-load",
|
||||
"Load files in the Hasselblad raw formats via %s",
|
||||
"This plug-in loads files in Hasselblad's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Sony"),
|
||||
"image/x-sony-arw,image/x-sony-srf,image/x-sony-sr2",
|
||||
"arw,srf,sr2",
|
||||
NULL,
|
||||
|
||||
"file-%s-sony-load",
|
||||
"Load files in the Sony raw formats via %s",
|
||||
"This plug-in loads files in Sony's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Casio BAY"),
|
||||
"image/x-casio-bay",
|
||||
"bay",
|
||||
NULL,
|
||||
|
||||
"file-%s-bay-load",
|
||||
"Load files in the BAY raw format via %s",
|
||||
"This plug-in loads files in Casio's raw BAY format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Phantom Software CINE"),
|
||||
"", /* FIXME: find a mime type */
|
||||
"cine,cin",
|
||||
NULL,
|
||||
|
||||
"file-%s-cine-load",
|
||||
"Load files in the CINE raw format via %s",
|
||||
"This plug-in loads files in Phantom Software's raw CINE format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Sinar"),
|
||||
"", /* FIXME: find a mime type */
|
||||
"cs1,ia,sti",
|
||||
NULL,
|
||||
|
||||
"file-%s-sinar-load",
|
||||
"Load files in the Sinar raw formats via %s",
|
||||
"This plug-in loads files in Sinar's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Kodak"),
|
||||
"image/x-kodak-dc2,image/x-kodak-dcr,image/x-kodak-kdc,image/x-kodak-k25,image/x-kodak-kc2",
|
||||
"dc2,dcr,kdc,k25,kc2",
|
||||
NULL,
|
||||
|
||||
"file-%s-kodak-load",
|
||||
"Load files in the Kodak raw formats via %s",
|
||||
"This plug-in loads files in Kodak's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Adobe DNG Digital Negative"),
|
||||
"image/x-adobe-dng",
|
||||
"dng",
|
||||
NULL,
|
||||
|
||||
"file-%s-dng-load",
|
||||
"Load files in the DNG raw format via %s",
|
||||
"This plug-in loads files in the Adobe Digital Negative DNG format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Epson ERF"),
|
||||
"image/x-epson-erf",
|
||||
"erf",
|
||||
NULL,
|
||||
|
||||
"file-%s-erf-load",
|
||||
"Load files in the ERF raw format via %s",
|
||||
"This plug-in loads files in Epson's raw ERF format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Phase One"),
|
||||
"image/x-phaseone-cap,image/x-phaseone-iiq",
|
||||
"cap,iiq",
|
||||
NULL,
|
||||
|
||||
"file-%s-phaseone-load",
|
||||
"Load files in the Phase One raw formats via %s",
|
||||
"This plug-in loads files in Phase One's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Minolta"),
|
||||
"image/x-minolta-mdc,image/x-minolta-mrw",
|
||||
"mdc,mrw",
|
||||
NULL,
|
||||
|
||||
"file-%s-minolta-load",
|
||||
"Load files in the Minolta raw formats via %s",
|
||||
"This plug-in loads files in Minolta's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Mamiya MEF"),
|
||||
"image/x-mamiya-mef",
|
||||
"mef", NULL,
|
||||
|
||||
"file-%s-mef-load",
|
||||
"Load files in the MEF raw format via %s",
|
||||
"This plug-in loads files in Mamiya's raw MEF format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Leaf MOS"),
|
||||
"image/x-leaf-mos",
|
||||
"mos",
|
||||
NULL,
|
||||
|
||||
"file-%s-mos-load",
|
||||
"Load files in the MOS raw format via %s",
|
||||
"This plug-in loads files in Leaf's raw MOS format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Olympus ORF"),
|
||||
"image/x-olympus-orf",
|
||||
"orf",
|
||||
"0,string,IIRO,0,string,MMOR,0,string,IIRS",
|
||||
|
||||
"file-%s-orf-load",
|
||||
"Load files in the ORF raw format via %s",
|
||||
"This plug-in loads files in Olympus' raw ORF format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Pentax PEF"),
|
||||
"image/x-pentax-pef,image/x-pentax-raw",
|
||||
"pef,raw",
|
||||
NULL,
|
||||
|
||||
"file-%s-pef-load",
|
||||
"Load files in the PEF raw format via %s",
|
||||
"This plug-in loads files in Pentax' raw PEF format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Logitech PXN"),
|
||||
"image/x-pxn", /* FIXME: is that the correct mime type? */
|
||||
"pxn",
|
||||
NULL,
|
||||
|
||||
"file-%s-pxn-load",
|
||||
"Load files in the PXN raw format via %s",
|
||||
"This plug-in loads files in Logitech's raw PXN format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Apple QuickTake QTK"),
|
||||
"", /* FIXME: find a mime type */
|
||||
"qtk",
|
||||
NULL,
|
||||
|
||||
"file-%s-qtk-load",
|
||||
"Load files in the QTK raw format via %s",
|
||||
"This plug-in loads files in Apple's QuickTake QTK raw format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Fujifilm RAF"),
|
||||
"image/x-fuji-raf",
|
||||
"raf",
|
||||
"0,string,FUJIFILMCCD-RAW",
|
||||
|
||||
"file-%s-raf-load",
|
||||
"Load files in the RAF raw format via %s",
|
||||
"This plug-in loads files in Fujifilm's raw RAF format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Panasonic"),
|
||||
"image/x-panasonic-raw,image/x-panasonic-rw2",
|
||||
"raw,rw2",
|
||||
"0,string,IIU\\0",
|
||||
|
||||
"file-%s-panasonic-load",
|
||||
"Load files in the Panasonic raw formats via %s",
|
||||
"This plug-in loads files in Panasonic's raw formats by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Digital Foto Maker RDC"),
|
||||
"", /* FIXME: find a mime type */
|
||||
"rdc",
|
||||
NULL,
|
||||
|
||||
"file-%s-rdc-load",
|
||||
"Load files in the RDC raw format via %s",
|
||||
"This plug-in loads files in Digital Foto Maker's raw RDC format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Leica RWL"),
|
||||
"image/x-leica-rwl",
|
||||
"rwl",
|
||||
NULL,
|
||||
|
||||
"file-%s-rwl-load",
|
||||
"Load files in the RWL raw format via %s",
|
||||
"This plug-in loads files in Leica's raw RWL format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Samsung SRW"),
|
||||
"image/x-samsung-srw",
|
||||
"srw",
|
||||
NULL,
|
||||
|
||||
"file-%s-srw-load",
|
||||
"Load files in the SRW raw format via %s",
|
||||
"This plug-in loads files in Samsung's raw SRW format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Sigma X3F"),
|
||||
"image/x-sigma-x3f",
|
||||
"x3f",
|
||||
"0,string,FOVb",
|
||||
|
||||
"file-%s-x3f-load",
|
||||
"Load files in the X3F raw format via %s",
|
||||
"This plug-in loads files in Sigma's raw X3F format by calling %s."
|
||||
},
|
||||
|
||||
{
|
||||
N_("Raw Arriflex ARI"),
|
||||
"",
|
||||
"ari",
|
||||
NULL,
|
||||
|
||||
"file-%s-ari-load",
|
||||
"Load files in the ARI raw format via %s",
|
||||
"This plug-in loads files in Arriflex' raw ARI format by calling %s."
|
||||
}
|
||||
};
|
189
plug-ins/file-raw/file-raw-placeholder.c
Normal file
189
plug-ins/file-raw/file-raw-placeholder.c
Normal file
@ -0,0 +1,189 @@
|
||||
/* PIKA - Photo and Image Kooker Application
|
||||
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
||||
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
||||
*
|
||||
* Original copyright, applying to most contents (license remains unchanged):
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* file-raw-placeholder.c -- raw file format plug-in that does nothing
|
||||
* except warning that there is no raw plug-in
|
||||
* Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <libpika/pika.h>
|
||||
|
||||
#include "libpika/stdplugins-intl.h"
|
||||
|
||||
#include "file-raw-formats.h"
|
||||
|
||||
|
||||
typedef struct _Placeholder Placeholder;
|
||||
typedef struct _PlaceholderClass PlaceholderClass;
|
||||
|
||||
struct _Placeholder
|
||||
{
|
||||
PikaPlugIn parent_instance;
|
||||
};
|
||||
|
||||
struct _PlaceholderClass
|
||||
{
|
||||
PikaPlugInClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
#define PLACEHOLDER_TYPE (placeholder_get_type ())
|
||||
#define PLACEHOLDER (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLACEHOLDER_TYPE, Placeholder))
|
||||
|
||||
GType placeholder_get_type (void) G_GNUC_CONST;
|
||||
|
||||
static GList * placeholder_query_procedures (PikaPlugIn *plug_in);
|
||||
static PikaProcedure * placeholder_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
static PikaValueArray * placeholder_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (Placeholder, placeholder, PIKA_TYPE_PLUG_IN)
|
||||
|
||||
PIKA_MAIN (PLACEHOLDER_TYPE)
|
||||
DEFINE_STD_SET_I18N
|
||||
|
||||
|
||||
static void
|
||||
placeholder_class_init (PlaceholderClass *klass)
|
||||
{
|
||||
PikaPlugInClass *plug_in_class = PIKA_PLUG_IN_CLASS (klass);
|
||||
|
||||
plug_in_class->query_procedures = placeholder_query_procedures;
|
||||
plug_in_class->create_procedure = placeholder_create_procedure;
|
||||
plug_in_class->set_i18n = STD_SET_I18N;
|
||||
}
|
||||
|
||||
static void
|
||||
placeholder_init (Placeholder *placeholder)
|
||||
{
|
||||
}
|
||||
|
||||
static GList *
|
||||
placeholder_query_procedures (PikaPlugIn *plug_in)
|
||||
{
|
||||
GList *list = NULL;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
|
||||
{
|
||||
const FileFormat *format = &file_formats[i];
|
||||
gchar *load_proc;
|
||||
|
||||
load_proc = g_strdup_printf (format->load_proc_format,
|
||||
"raw-placeholder");
|
||||
|
||||
list = g_list_append (list, load_proc);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static PikaProcedure *
|
||||
placeholder_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
PikaProcedure *procedure = NULL;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
|
||||
{
|
||||
const FileFormat *format = &file_formats[i];
|
||||
gchar *load_proc;
|
||||
gchar *load_blurb;
|
||||
gchar *load_help;
|
||||
|
||||
load_proc = g_strdup_printf (format->load_proc_format,
|
||||
"raw-placeholder");
|
||||
|
||||
if (strcmp (name, load_proc))
|
||||
{
|
||||
g_free (load_proc);
|
||||
continue;
|
||||
}
|
||||
|
||||
load_blurb = g_strdup_printf (format->load_blurb_format, "placeholder");
|
||||
load_help = g_strdup_printf (format->load_help_format, "placeholder");
|
||||
|
||||
procedure = pika_load_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
placeholder_load,
|
||||
(gpointer) format, NULL);
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
load_blurb, load_help, name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Tobias Ellinghaus",
|
||||
"Tobias Ellinghaus",
|
||||
"2016");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->mime_type);
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->extensions);
|
||||
pika_file_procedure_set_magics (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->magic);
|
||||
|
||||
pika_load_procedure_set_handles_raw (PIKA_LOAD_PROCEDURE (procedure),
|
||||
TRUE);
|
||||
|
||||
g_free (load_proc);
|
||||
g_free (load_blurb);
|
||||
g_free (load_help);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
placeholder_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
const FileFormat *format = run_data;
|
||||
GError *error = NULL;
|
||||
|
||||
g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("There is no RAW loader installed to open '%s' files.\n"
|
||||
"\n"
|
||||
"PIKA currently supports these RAW loaders:\n"
|
||||
"- darktable (http://www.darktable.org/), at least 1.7\n"
|
||||
"- RawTherapee (http://rawtherapee.com/), at least 5.2\n"
|
||||
"\n"
|
||||
"Please install one of them in order to "
|
||||
"load RAW files."),
|
||||
gettext (format->file_type));
|
||||
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
}
|
157
plug-ins/file-raw/file-raw-utils.c
Normal file
157
plug-ins/file-raw/file-raw-utils.c
Normal file
@ -0,0 +1,157 @@
|
||||
/* PIKA - Photo and Image Kooker Application
|
||||
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
||||
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
||||
*
|
||||
* Original copyright, applying to most contents (license remains unchanged):
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* file-raw-utils.h -- raw file format plug-in
|
||||
* Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <libpika/pika.h>
|
||||
|
||||
#include "file-raw-utils.h"
|
||||
|
||||
|
||||
gchar *
|
||||
file_raw_get_executable_path (const gchar *main_executable,
|
||||
const gchar *suffix,
|
||||
const gchar *env_variable,
|
||||
const gchar *mac_bundle_id,
|
||||
const gchar *win32_registry_key_base,
|
||||
gboolean *search_path)
|
||||
{
|
||||
/*
|
||||
* First check for the environment variable.
|
||||
* Next do platform specific checks (bundle lookup on Mac, registry stuff
|
||||
* on Windows).
|
||||
* Last resort is hoping for the executable to be in PATH.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Look for env variable. That can be set directly or via an environ file.
|
||||
* We assume that just appending the suffix to that value will work.
|
||||
* That means that on Windows there should be no ".exe"!
|
||||
*/
|
||||
const gchar *dt_env = env_variable ? g_getenv (env_variable) : NULL;
|
||||
|
||||
if (dt_env)
|
||||
return g_strconcat (dt_env, suffix, NULL);
|
||||
|
||||
#if defined (GDK_WINDOWING_QUARTZ)
|
||||
if (mac_bundle_id)
|
||||
{
|
||||
CFStringRef bundle_id;
|
||||
|
||||
/* For macOS, attempt searching for an app bundle first. */
|
||||
bundle_id = CFStringCreateWithCString (NULL, mac_bundle_id,
|
||||
kCFStringEncodingUTF8);
|
||||
if (bundle_id)
|
||||
{
|
||||
OSStatus status;
|
||||
CFURLRef bundle_url = NULL;
|
||||
|
||||
status = LSFindApplicationForInfo (kLSUnknownCreator,
|
||||
bundle_id, NULL, NULL,
|
||||
&bundle_url);
|
||||
if (status >= 0)
|
||||
{
|
||||
CFBundleRef bundle;
|
||||
CFURLRef exec_url, absolute_url;
|
||||
CFStringRef path;
|
||||
gchar *ret;
|
||||
CFIndex len;
|
||||
|
||||
bundle = CFBundleCreate (kCFAllocatorDefault, bundle_url);
|
||||
CFRelease (bundle_url);
|
||||
|
||||
exec_url = CFBundleCopyExecutableURL (bundle);
|
||||
absolute_url = CFURLCopyAbsoluteURL (exec_url);
|
||||
path = CFURLCopyFileSystemPath (absolute_url, kCFURLPOSIXPathStyle);
|
||||
|
||||
/* This gets us the length in UTF16 characters, we multiply by 2
|
||||
* to make sure we have a buffer big enough to fit the UTF8 string.
|
||||
*/
|
||||
len = CFStringGetLength (path);
|
||||
ret = g_malloc0 (len * 2 * sizeof (gchar));
|
||||
if (! CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
|
||||
kCFStringEncodingUTF8))
|
||||
ret = NULL;
|
||||
|
||||
CFRelease (path);
|
||||
CFRelease (absolute_url);
|
||||
CFRelease (exec_url);
|
||||
CFRelease (bundle);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
CFRelease (bundle_id);
|
||||
}
|
||||
/* else, app bundle was not found, try path search as last resort. */
|
||||
}
|
||||
|
||||
#elif defined (GDK_WINDOWING_WIN32)
|
||||
if (win32_registry_key_base)
|
||||
{
|
||||
/* Look for the application in the Windows registry. */
|
||||
char *registry_key;
|
||||
char path[MAX_PATH];
|
||||
DWORD buffer_size = sizeof (path);
|
||||
long status;
|
||||
|
||||
if (suffix)
|
||||
registry_key = g_strconcat (win32_registry_key_base, suffix, ".exe", NULL);
|
||||
else
|
||||
registry_key = g_strconcat (win32_registry_key_base, ".exe", NULL);
|
||||
|
||||
/* Check HKCU first in case there is a user specific installation. */
|
||||
status = RegGetValue (HKEY_CURRENT_USER, registry_key, "", RRF_RT_ANY,
|
||||
NULL, (PVOID)&path, &buffer_size);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
status = RegGetValue (HKEY_LOCAL_MACHINE, registry_key, "", RRF_RT_ANY,
|
||||
NULL, (PVOID)&path, &buffer_size);
|
||||
|
||||
g_free (registry_key);
|
||||
|
||||
if (status == ERROR_SUCCESS)
|
||||
return g_strdup (path);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Finally, the last resort. */
|
||||
*search_path = TRUE;
|
||||
|
||||
if (suffix)
|
||||
return g_strconcat (main_executable, suffix, NULL);
|
||||
|
||||
return g_strdup (main_executable);
|
||||
}
|
37
plug-ins/file-raw/file-raw-utils.h
Normal file
37
plug-ins/file-raw/file-raw-utils.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* PIKA - Photo and Image Kooker Application
|
||||
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
||||
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
||||
*
|
||||
* Original copyright, applying to most contents (license remains unchanged):
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* file-raw-utils.h -- raw file format plug-in
|
||||
* Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __FILE_RAW_UTILS_H__
|
||||
#define __FILE_RAW_UTILS_H__
|
||||
|
||||
|
||||
gchar * file_raw_get_executable_path (const gchar *main_executable,
|
||||
const gchar *suffix,
|
||||
const gchar *env_variable,
|
||||
const gchar *mac_bundle_id,
|
||||
const gchar *win32_registry_key_base,
|
||||
gboolean *search_path);
|
||||
|
||||
|
||||
#endif /* __FILE_RAW_UTILS_H__ */
|
490
plug-ins/file-raw/file-rawtherapee.c
Normal file
490
plug-ins/file-raw/file-rawtherapee.c
Normal file
@ -0,0 +1,490 @@
|
||||
/* PIKA - Photo and Image Kooker Application
|
||||
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
||||
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
||||
*
|
||||
* Original copyright, applying to most contents (license remains unchanged):
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* file-rawtherapee.c -- raw file format plug-in that uses RawTherapee
|
||||
* Copyright (C) 2012 Simon Budig <simon@gimp.org>
|
||||
* Copyright (C) 2016 Tobias Ellinghaus <me@houz.org>
|
||||
* Copyright (C) 2017 Alberto Griggio <alberto.griggio@gmail.com>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <libpika/pika.h>
|
||||
|
||||
#include "libpika/stdplugins-intl.h"
|
||||
|
||||
#include "file-raw-formats.h"
|
||||
#include "file-raw-utils.h"
|
||||
|
||||
|
||||
#define LOAD_THUMB_PROC "file-rawtherapee-load-thumb"
|
||||
#define REGISTRY_KEY_BASE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee"
|
||||
|
||||
|
||||
typedef struct _Rawtherapee Rawtherapee;
|
||||
typedef struct _RawtherapeeClass RawtherapeeClass;
|
||||
|
||||
struct _Rawtherapee
|
||||
{
|
||||
PikaPlugIn parent_instance;
|
||||
};
|
||||
|
||||
struct _RawtherapeeClass
|
||||
{
|
||||
PikaPlugInClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
#define RAWTHERAPEE_TYPE (rawtherapee_get_type ())
|
||||
#define RAWTHERAPEE (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RAWTHERAPEE_TYPE, Rawtherapee))
|
||||
|
||||
GType rawtherapee_get_type (void) G_GNUC_CONST;
|
||||
|
||||
static GList * rawtherapee_init_procedures (PikaPlugIn *plug_in);
|
||||
static PikaProcedure * rawtherapee_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
static PikaValueArray * rawtherapee_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
static PikaValueArray * rawtherapee_load_thumb (PikaProcedure *procedure,
|
||||
GFile *file,
|
||||
gint size,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
|
||||
static PikaImage * load_image (GFile *file,
|
||||
PikaRunMode run_mode,
|
||||
GError **error);
|
||||
static PikaImage * load_thumbnail_image (GFile *file,
|
||||
gint thumb_size,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (Rawtherapee, rawtherapee, PIKA_TYPE_PLUG_IN)
|
||||
|
||||
PIKA_MAIN (RAWTHERAPEE_TYPE)
|
||||
DEFINE_STD_SET_I18N
|
||||
|
||||
|
||||
static void
|
||||
rawtherapee_class_init (RawtherapeeClass *klass)
|
||||
{
|
||||
PikaPlugInClass *plug_in_class = PIKA_PLUG_IN_CLASS (klass);
|
||||
|
||||
plug_in_class->init_procedures = rawtherapee_init_procedures;
|
||||
plug_in_class->create_procedure = rawtherapee_create_procedure;
|
||||
plug_in_class->set_i18n = STD_SET_I18N;
|
||||
}
|
||||
|
||||
static void
|
||||
rawtherapee_init (Rawtherapee *rawtherapee)
|
||||
{
|
||||
}
|
||||
|
||||
static GList *
|
||||
rawtherapee_init_procedures (PikaPlugIn *plug_in)
|
||||
{
|
||||
/* check if rawtherapee is installed
|
||||
* TODO: allow setting the location of the executable in preferences
|
||||
*/
|
||||
gboolean search_path = FALSE;
|
||||
gchar *exec_path = file_raw_get_executable_path ("rawtherapee", NULL,
|
||||
"RAWTHERAPEE_EXECUTABLE",
|
||||
"com.rawtherapee.rawtherapee",
|
||||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
#ifdef G_OS_WIN32
|
||||
/* Issue #2716 - Prevent RT from opening a console window */
|
||||
gchar *argv[] = { exec_path, "-v", "-w", NULL };
|
||||
#else
|
||||
gchar *argv[] = { exec_path, "-v", NULL };
|
||||
#endif
|
||||
gchar *rawtherapee_stdout = NULL;
|
||||
gboolean have_rawtherapee = FALSE;
|
||||
gint i;
|
||||
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0) |
|
||||
G_SPAWN_STDERR_TO_DEV_NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&rawtherapee_stdout,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
gint rtmajor = 0;
|
||||
gint rtminor = 0;
|
||||
|
||||
if (sscanf (rawtherapee_stdout,
|
||||
"RawTherapee, version %d.%d",
|
||||
&rtmajor, &rtminor) == 2 &&
|
||||
((rtmajor == 5 && rtminor >= 2) || rtmajor >= 6))
|
||||
{
|
||||
have_rawtherapee = TRUE;
|
||||
}
|
||||
|
||||
g_free (rawtherapee_stdout);
|
||||
}
|
||||
|
||||
g_free (exec_path);
|
||||
|
||||
if (have_rawtherapee)
|
||||
{
|
||||
GList *list = NULL;
|
||||
|
||||
list = g_list_append (list, g_strdup (LOAD_THUMB_PROC));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
|
||||
{
|
||||
const FileFormat *format = &file_formats[i];
|
||||
gchar *load_proc;
|
||||
|
||||
load_proc = g_strdup_printf (format->load_proc_format, "rawtherapee");
|
||||
|
||||
list = g_list_append (list, load_proc);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PikaProcedure *
|
||||
rawtherapee_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
PikaProcedure *procedure = NULL;
|
||||
|
||||
if (! strcmp (name, LOAD_THUMB_PROC))
|
||||
{
|
||||
procedure = pika_thumbnail_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
rawtherapee_load_thumb, NULL, NULL);
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
"Load thumbnail from a raw image "
|
||||
"via rawtherapee",
|
||||
"This plug-in loads a thumbnail "
|
||||
"from a raw image by calling "
|
||||
"rawtherapee-cli.",
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Alberto Griggio",
|
||||
"Alberto Griggio",
|
||||
"2017");
|
||||
}
|
||||
else
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (file_formats); i++)
|
||||
{
|
||||
const FileFormat *format = &file_formats[i];
|
||||
gchar *load_proc;
|
||||
gchar *load_blurb;
|
||||
gchar *load_help;
|
||||
|
||||
load_proc = g_strdup_printf (format->load_proc_format, "rawtherapee");
|
||||
|
||||
if (strcmp (name, load_proc))
|
||||
{
|
||||
g_free (load_proc);
|
||||
continue;
|
||||
}
|
||||
|
||||
load_blurb = g_strdup_printf (format->load_blurb_format, "rawtherapee");
|
||||
load_help = g_strdup_printf (format->load_help_format, "rawtherapee");
|
||||
|
||||
procedure = pika_load_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
rawtherapee_load,
|
||||
(gpointer) format, NULL);
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
load_blurb, load_help, name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Alberto Griggio",
|
||||
"Alberto Griggio",
|
||||
"2017");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->mime_type);
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->extensions);
|
||||
pika_file_procedure_set_magics (PIKA_FILE_PROCEDURE (procedure),
|
||||
format->magic);
|
||||
|
||||
pika_load_procedure_set_handles_raw (PIKA_LOAD_PROCEDURE (procedure),
|
||||
TRUE);
|
||||
pika_load_procedure_set_thumbnail_loader (PIKA_LOAD_PROCEDURE (procedure),
|
||||
LOAD_THUMB_PROC);
|
||||
|
||||
g_free (load_proc);
|
||||
g_free (load_blurb);
|
||||
g_free (load_help);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
rawtherapee_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaValueArray *return_vals;
|
||||
PikaImage *image;
|
||||
GError *error = NULL;
|
||||
|
||||
image = load_image (file, run_mode, &error);
|
||||
|
||||
if (! image)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
|
||||
return_vals = pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
PIKA_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
rawtherapee_load_thumb (PikaProcedure *procedure,
|
||||
GFile *file,
|
||||
gint size,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaValueArray *return_vals;
|
||||
PikaImage *image;
|
||||
GError *error = NULL;
|
||||
|
||||
image = load_thumbnail_image (file, size, &error);
|
||||
|
||||
if (! image)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
|
||||
return_vals = pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
PIKA_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
PIKA_VALUES_SET_INT (return_vals, 2, 0);
|
||||
PIKA_VALUES_SET_INT (return_vals, 3, 0);
|
||||
PIKA_VALUES_SET_ENUM (return_vals, 4, PIKA_RGB_IMAGE);
|
||||
PIKA_VALUES_SET_INT (return_vals, 5, 1);
|
||||
|
||||
pika_value_array_truncate (return_vals, 6);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaImage *
|
||||
load_image (GFile *file,
|
||||
PikaRunMode run_mode,
|
||||
GError **error)
|
||||
{
|
||||
PikaImage *image = NULL;
|
||||
GFile *file_out = pika_temp_file ("tif");
|
||||
gchar *rawtherapee_stdout = NULL;
|
||||
|
||||
gboolean search_path = FALSE;
|
||||
gchar *exec_path = file_raw_get_executable_path ("rawtherapee", NULL,
|
||||
"RAWTHERAPEE_EXECUTABLE",
|
||||
"com.rawtherapee.rawtherapee",
|
||||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
|
||||
/* linear sRGB for now as PIKA uses that internally in many places anyway */
|
||||
gchar *argv[] =
|
||||
{
|
||||
exec_path,
|
||||
"-pika",
|
||||
(gchar *) g_file_peek_path (file),
|
||||
(gchar *) g_file_peek_path (file_out),
|
||||
NULL
|
||||
};
|
||||
|
||||
pika_progress_init_printf (_("Opening '%s'"),
|
||||
pika_file_get_utf8_name (file));
|
||||
|
||||
if (g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
/*G_SPAWN_STDOUT_TO_DEV_NULL |*/
|
||||
G_SPAWN_STDERR_TO_DEV_NULL |
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0),
|
||||
NULL,
|
||||
NULL,
|
||||
&rawtherapee_stdout,
|
||||
NULL,
|
||||
NULL,
|
||||
error))
|
||||
{
|
||||
image = pika_file_load (run_mode, file_out);
|
||||
}
|
||||
|
||||
/*if (rawtherapee_stdout) printf ("%s\n", rawtherapee_stdout);*/
|
||||
g_free (rawtherapee_stdout);
|
||||
g_free (exec_path);
|
||||
|
||||
g_file_delete (file_out, NULL, NULL);
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static PikaImage *
|
||||
load_thumbnail_image (GFile *file,
|
||||
gint thumb_size,
|
||||
GError **error)
|
||||
{
|
||||
PikaImage *image = NULL;
|
||||
GFile *file_out = pika_temp_file ("jpg");
|
||||
GFile *thumb_pp3_file = pika_temp_file ("pp3");
|
||||
FILE *thumb_pp3_f = g_fopen (g_file_peek_path (thumb_pp3_file), "w");
|
||||
gchar *rawtherapee_stdout = NULL;
|
||||
const char *pp3_content =
|
||||
"[Version]\n"
|
||||
"AppVersion=5.0\n"
|
||||
"Version=326\n"
|
||||
"\n"
|
||||
"[Resize]\n"
|
||||
"Enabled=true\n"
|
||||
"AppliesTo=Cropped area\n"
|
||||
"Method=Lanczos\n"
|
||||
"Width=%d\n"
|
||||
"Height=%d\n"
|
||||
"\n"
|
||||
"[Sharpening]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[SharpenEdge]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[SharpenMicro]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[Defringing]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[Directional Pyramid Equalizer]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[PostResizeSharpening]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[Directional Pyramid Denoising]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[Impulse Denoising]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[Wavelet]\n"
|
||||
"Enabled=false\n"
|
||||
"\n"
|
||||
"[RAW Bayer]\n"
|
||||
"Method=fast\n"
|
||||
"\n"
|
||||
"[RAW X-Trans]\n"
|
||||
"Method=fast\n";
|
||||
|
||||
|
||||
gboolean search_path = FALSE;
|
||||
gchar *exec_path = file_raw_get_executable_path ("rawtherapee", "-cli",
|
||||
"RAWTHERAPEE_EXECUTABLE",
|
||||
"com.rawtherapee.rawtherapee",
|
||||
REGISTRY_KEY_BASE,
|
||||
&search_path);
|
||||
gchar *argv[] =
|
||||
{
|
||||
exec_path,
|
||||
"-o", (gchar *) g_file_peek_path (file_out),
|
||||
"-d",
|
||||
"-s",
|
||||
"-j",
|
||||
"-p", (gchar *) g_file_peek_path (thumb_pp3_file),
|
||||
"-f",
|
||||
"-c", (gchar *) g_file_peek_path (file),
|
||||
NULL
|
||||
};
|
||||
|
||||
if (thumb_pp3_f)
|
||||
{
|
||||
if (fprintf (thumb_pp3_f, pp3_content, thumb_size, thumb_size) < 0)
|
||||
{
|
||||
fclose (thumb_pp3_f);
|
||||
thumb_pp3_f = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
pika_progress_init_printf (_("Opening thumbnail for '%s'"),
|
||||
pika_file_get_utf8_name (file));
|
||||
|
||||
if (thumb_pp3_f &&
|
||||
g_spawn_sync (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
G_SPAWN_STDERR_TO_DEV_NULL |
|
||||
(search_path ? G_SPAWN_SEARCH_PATH : 0),
|
||||
NULL,
|
||||
NULL,
|
||||
&rawtherapee_stdout,
|
||||
NULL,
|
||||
NULL,
|
||||
error))
|
||||
{
|
||||
pika_progress_update (0.5);
|
||||
|
||||
image = pika_file_load (PIKA_RUN_NONINTERACTIVE, file_out);
|
||||
}
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
if (thumb_pp3_f)
|
||||
fclose (thumb_pp3_f);
|
||||
|
||||
g_file_delete (thumb_pp3_file, NULL, NULL);
|
||||
g_free (rawtherapee_stdout);
|
||||
g_free (exec_path);
|
||||
|
||||
return image;
|
||||
}
|
48
plug-ins/file-raw/meson.build
Normal file
48
plug-ins/file-raw/meson.build
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
file_raw_exes = [
|
||||
'file-darktable',
|
||||
'file-raw-placeholder',
|
||||
'file-rawtherapee',
|
||||
]
|
||||
|
||||
foreach plugin_name : file_raw_exes
|
||||
|
||||
plugin_sources = [
|
||||
plugin_name +'.c',
|
||||
'file-raw-utils.c',
|
||||
]
|
||||
|
||||
if platform_windows
|
||||
plugin_rc = configure_file(
|
||||
input : pika_plugins_rc.full_path(),
|
||||
output: plugin_name + '.rc',
|
||||
copy: true,
|
||||
)
|
||||
plugin_sources += windows.compile_resources(
|
||||
plugin_rc,
|
||||
args: [
|
||||
'--define', 'ORIGINALFILENAME_STR="@0@"'.format(plugin_name+'.exe'),
|
||||
'--define', 'INTERNALNAME_STR="@0@"' .format(plugin_name),
|
||||
'--define', 'TOP_SRCDIR="@0@"' .format(meson.project_source_root()),
|
||||
],
|
||||
include_directories: [
|
||||
rootInclude, appInclude,
|
||||
],
|
||||
)
|
||||
endif
|
||||
|
||||
|
||||
executable(plugin_name,
|
||||
plugin_sources,
|
||||
dependencies: libpikaui_dep,
|
||||
install: true,
|
||||
install_dir: pikaplugindir / 'plug-ins' / plugin_name,
|
||||
)
|
||||
endforeach
|
||||
|
||||
install_data([
|
||||
'file-darktable-export-on-exit.lua',
|
||||
'file-darktable-get-size.lua',
|
||||
],
|
||||
install_dir: prefix / pikadatadir / 'file-raw',
|
||||
)
|
Reference in New Issue
Block a user