Gimp plugin: removed magic numbers from the file formats -- we rely only on file extensions

This commit is contained in:
Alberto Griggio 2017-06-19 13:51:37 +02:00
parent 6b28671c41
commit 3bfda08bcf
2 changed files with 7 additions and 40 deletions

View File

@ -38,20 +38,13 @@ struct _FileFormat
#define N_(s) s #define N_(s) s
#define _(s) s #define _(s) s
/* 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[] = static const FileFormat file_formats[] =
{ {
{ {
N_("Raw Canon"), N_("Raw Canon"),
"image/x-canon-cr2,image/x-canon-crw", "image/x-canon-cr2,image/x-canon-crw",
"cr2,crw", "cr2,crw",
"0,string,II*\\0\\020\\0\\0\\0CR," /* cr2 */ NULL,
"0,string,II\\024\\0\\0\\0HEAPCCDR," /* crw */
"file-rawtherapee-canon-load", "file-rawtherapee-canon-load",
"Load files in the Canon raw formats via rawtherapee", "Load files in the Canon raw formats via rawtherapee",
@ -204,7 +197,7 @@ static const FileFormat file_formats[] =
N_("Raw Olympus ORF"), N_("Raw Olympus ORF"),
"image/x-olympus-orf", "image/x-olympus-orf",
"orf", "orf",
"0,string,IIRO,0,string,MMOR,0,string,IIRS", NULL,
"file-rawtherapee-orf-load", "file-rawtherapee-orf-load",
"Load files in the ORF raw format via rawtherapee", "Load files in the ORF raw format via rawtherapee",
@ -248,7 +241,7 @@ static const FileFormat file_formats[] =
N_("Raw Fujifilm RAF"), N_("Raw Fujifilm RAF"),
"image/x-fuji-raf", "image/x-fuji-raf",
"raf", "raf",
"0,string,FUJIFILMCCD-RAW", NULL,
"file-rawtherapee-raf-load", "file-rawtherapee-raf-load",
"Load files in the RAF raw format via rawtherapee", "Load files in the RAF raw format via rawtherapee",
@ -259,7 +252,7 @@ static const FileFormat file_formats[] =
N_("Raw Panasonic"), N_("Raw Panasonic"),
"image/x-panasonic-raw,image/x-panasonic-rw2", "image/x-panasonic-raw,image/x-panasonic-rw2",
"raw,rw2", "raw,rw2",
"0,string,IIU\\0", NULL,
"file-rawtherapee-panasonic-load", "file-rawtherapee-panasonic-load",
"Load files in the Panasonic raw formats via rawtherapee", "Load files in the Panasonic raw formats via rawtherapee",
@ -303,7 +296,7 @@ static const FileFormat file_formats[] =
N_("Raw Sigma X3F"), N_("Raw Sigma X3F"),
"image/x-sigma-x3f", "image/x-sigma-x3f",
"x3f", "x3f",
"0,string,FOVb", NULL,
"file-rawtherapee-x3f-load", "file-rawtherapee-x3f-load",
"Load files in the X3F raw format via rawtherapee", "Load files in the X3F raw format via rawtherapee",

View File

@ -51,8 +51,6 @@ static gint32 load_image (const gchar *filename,
static gint32 load_thumbnail_image (const gchar *filename, static gint32 load_thumbnail_image (const gchar *filename,
gint thumb_size, gint thumb_size,
gint *width,
gint *height,
GError **error); GError **error);
const GimpPlugInInfo PLUG_IN_INFO = const GimpPlugInInfo PLUG_IN_INFO =
@ -89,9 +87,7 @@ query (void)
static const GimpParamDef thumb_return_vals[] = static const GimpParamDef thumb_return_vals[] =
{ {
{ GIMP_PDB_IMAGE, "image", "Thumbnail image" }, { GIMP_PDB_IMAGE, "image", "Thumbnail image" }
{ GIMP_PDB_INT32, "image-width", "Width of full-sized image" },
{ GIMP_PDB_INT32, "image-height", "Height of full-sized image" }
}; };
/* check if rawtherapee is installed /* check if rawtherapee is installed
@ -220,24 +216,15 @@ run (const gchar *name,
} }
else if (! strcmp (name, LOAD_THUMB_PROC)) else if (! strcmp (name, LOAD_THUMB_PROC))
{ {
gint width = 0;
gint height = 0;
image_ID = load_thumbnail_image (param[0].data.d_string, image_ID = load_thumbnail_image (param[0].data.d_string,
param[1].data.d_int32, param[1].data.d_int32,
&width,
&height,
&error); &error);
if (image_ID != -1) if (image_ID != -1)
{ {
*nreturn_vals = 6; *nreturn_vals = 4;
values[1].type = GIMP_PDB_IMAGE; values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image_ID; values[1].data.d_image = image_ID;
values[2].type = GIMP_PDB_INT32;
values[2].data.d_int32 = width;
values[3].type = GIMP_PDB_INT32;
values[3].data.d_int32 = height;
values[4].type = GIMP_PDB_INT32; values[4].type = GIMP_PDB_INT32;
values[4].data.d_int32 = GIMP_RGB_IMAGE; values[4].data.d_int32 = GIMP_RGB_IMAGE;
values[5].type = GIMP_PDB_INT32; values[5].type = GIMP_PDB_INT32;
@ -320,8 +307,6 @@ load_image (const gchar *filename,
static gint32 static gint32
load_thumbnail_image (const gchar *filename, load_thumbnail_image (const gchar *filename,
gint thumb_size, gint thumb_size,
gint *width,
gint *height,
GError **error) GError **error)
{ {
gint32 image_ID = -1; gint32 image_ID = -1;
@ -400,8 +385,6 @@ load_thumbnail_image (const gchar *filename,
gimp_progress_init_printf (_("Opening thumbnail for '%s'"), gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
gimp_filename_to_utf8 (filename)); gimp_filename_to_utf8 (filename));
*width = *height = thumb_size;
if (thumb_pp3_f && if (thumb_pp3_f &&
g_spawn_sync (NULL, g_spawn_sync (NULL,
argv, argv,
@ -422,15 +405,6 @@ load_thumbnail_image (const gchar *filename,
filename_out); filename_out);
if (image_ID != -1) if (image_ID != -1)
{ {
/* /\* 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 (rawtherapee_stdout, */
/* -1, */
/* "[dt4gimp]"); */
/* if (start_of_size) */
/* sscanf (start_of_size, "[dt4gimp] %d %d", width, height); */
/* is this needed for thumbnails? */ /* is this needed for thumbnails? */
gimp_image_set_filename (image_ID, filename); gimp_image_set_filename (image_ID, filename);
} }