Skip to content

Commit

Permalink
2.4: Added support to OpenEXR images
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrofrancesconi committed Apr 29, 2020
1 parent 175c744 commit 249432e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ BIMP. Batch Image Manipulation Plugin for GIMP.
Changelog
---------

2.4
- Added support to OpenEXR images

2.3
- Added Dutch translation (thanks to Just Vecht & Paul Matthijsse from Dutch Helpmij Magazine)
- Fixed zh-CN locale (thanks to @KrasnayaPloshchad)
Expand Down
14 changes: 10 additions & 4 deletions src/bimp-gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ static void add_input_folder_r(char* folder, gboolean with_subdirs)
g_ascii_strcasecmp(file_extension, ".svg") == 0 ||
g_ascii_strcasecmp(file_extension, ".webp") == 0 ||
g_ascii_strcasecmp(file_extension, ".xpm") == 0 ||
g_ascii_strcasecmp(file_extension, ".exr") == 0 ||
g_ascii_strcasecmp(file_extension, ".xcf") == 0) &&
g_slist_find_custom(bimp_input_filenames, filename, (GCompareFunc)strcmp) == NULL)
{
Expand Down Expand Up @@ -589,7 +590,7 @@ static void open_file_chooser(GtkWidget *widget, gpointer data)
{
GSList *selection;

GtkFileFilter *filter_all, *supported[13];
GtkFileFilter *filter_all, *supported[14];

GtkWidget* file_chooser = gtk_file_chooser_dialog_new(
_("Select images"),
Expand Down Expand Up @@ -672,13 +673,18 @@ static void open_file_chooser(GtkWidget *widget, gpointer data)
gtk_file_filter_add_pattern (filter_all, "*.[xX][pP][mM]");

supported[12] = gtk_file_filter_new();
gtk_file_filter_set_name(supported[12], "GIMP XCF (*.xcf)");
gtk_file_filter_add_pattern (supported[12], "*.[xX][cC][fF]");
gtk_file_filter_set_name(supported[12], "OpenEXR (*.exr)");
gtk_file_filter_add_pattern (supported[12], "*.[eE][xX][rR]");
gtk_file_filter_add_pattern (filter_all, "*.[eE][xX][rR]");

supported[13] = gtk_file_filter_new();
gtk_file_filter_set_name(supported[13], "GIMP XCF (*.xcf)");
gtk_file_filter_add_pattern (supported[13], "*.[xX][cC][fF]");
gtk_file_filter_add_pattern (filter_all, "*.[xX][cC][fF]");

gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser), filter_all);
size_t i;
for(i = 0; i < 13; i++) {
for(i = 0; i < 14; i++) {
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser), supported[i]);
}

Expand Down
6 changes: 4 additions & 2 deletions src/bimp-manipulations.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef enum format_type {
FORMAT_TIFF,
FORMAT_HEIF,
FORMAT_WEBP,
FORMAT_EXR,
FORMAT_END
} format_type;
static const char* format_type_string[][2] = {
Expand All @@ -91,8 +92,9 @@ static const char* format_type_string[][2] = {
{"png", "Portable Network Graphics (.png)"}, /* FORMAT_PNG */
{"tga", "Targa (.tga)"}, /* FORMAT_TGA */
{"tiff", "Tagged Image File Format (.tiff)"}, /* FORMAT_TIFF */
{"heif", "Heif (.heif)"}, /* FORMAT_HEIF */
{"webp", "WebP (.webp)"} /* FORMAT_HEIF */
{"heif", "Heif (.heif)"}, /* FORMAT_HEIF */
{"webp", "WebP (.webp)"}, /* FORMAT_WEBP */
{"exr", "OpenEXR (.exr)"} /* FORMAT_EXR */
};

// First two bits = column, second two bits = row
Expand Down
23 changes: 23 additions & 0 deletions src/bimp-operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static gboolean image_save_png(image_output, gboolean, int, gboolean, gboolean,
static gboolean image_save_tga(image_output, gboolean, int);
static gboolean image_save_tiff(image_output, int);
static gboolean image_save_webp(image_output, int, gboolean, float, float, gboolean, gboolean, gboolean, int, gboolean, gboolean, gboolean, int, int);
static gboolean image_save_exr(image_output);

static int overwrite_result(char*, GtkWidget*);

Expand Down Expand Up @@ -1087,6 +1088,9 @@ static gboolean image_save(format_type type, image_output imageout, format_param
((format_params_webp)params)->force_delay
);
}
else if(type == FORMAT_EXR) {
result = image_save_exr(imageout);
}
else {
// save in the original format
int final_drawable = gimp_image_merge_visible_layers(imageout->image_id, GIMP_CLIP_TO_IMAGE);
Expand Down Expand Up @@ -1371,6 +1375,25 @@ static gboolean image_save_webp(image_output out, int preset, gboolean lossless,
return TRUE;
}

static gboolean image_save_exr(image_output out)
{
gint nreturn_vals;
int final_drawable = gimp_image_merge_visible_layers(out->image_id, GIMP_CLIP_TO_IMAGE);

GimpParam *return_vals = gimp_run_procedure(
"file_exr_save",
&nreturn_vals,
GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
GIMP_PDB_IMAGE, out->image_id,
GIMP_PDB_DRAWABLE, final_drawable,
GIMP_PDB_STRING, out->filepath,
GIMP_PDB_STRING, out->filename,
GIMP_PDB_END
);

return TRUE;
}

/* returns a result code following this schema:
* 0 = user responses "don't overwrite" to a confirm dialog
* 1 = old file was the same as the new one and user responses "yes, overwrite"
Expand Down
2 changes: 1 addition & 1 deletion src/bimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define PLUG_IN_WEBSITE "http://www.alessandrofrancesconi.it/projects/bimp"
#define PLUG_IN_BINARY "bimp"
#define PLUG_IN_PROC "plug-in-bimp"
#define PLUG_IN_VERSION "2.3"
#define PLUG_IN_VERSION "2.4"

#define BIMP_RESULT_OK 1
#define BIMP_RESULT_WARNING 0
Expand Down

0 comments on commit 249432e

Please sign in to comment.