Mercurial > hg > forks > geeqie
changeset 2848:ed4e22060177
Fix #635: Export in JPG
https://github.com/BestImageViewer/geeqie/issues/635
Implemented via plugin
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Sun, 14 Oct 2018 12:40:03 +0100 |
parents | 53785dd2e8c9 |
children | 17b72aa3147b |
files | configure.in plugins/Makefile.am plugins/export-jpeg/Makefile.am plugins/export-jpeg/export-jpeg.desktop.in plugins/export-jpeg/geeqie-export-jpeg src/remote.c web/geeqie-install-debian.sh |
diffstat | 7 files changed, 145 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Sun Oct 14 10:39:17 2018 +0100 +++ b/configure.in Sun Oct 14 12:40:03 2018 +0100 @@ -619,6 +619,7 @@ plugins/ufraw/Makefile plugins/import/Makefile plugins/geocode-parameters/Makefile + plugins/export-jpeg/Makefile geeqie.spec ])
--- a/plugins/Makefile.am Sun Oct 14 10:39:17 2018 +0100 +++ b/plugins/Makefile.am Sun Oct 14 12:40:03 2018 +0100 @@ -1,6 +1,6 @@ #FIXME enable or disable individual plugins from configure -SUBDIRS = rotate symlink ufraw import geocode-parameters +SUBDIRS = rotate symlink ufraw import geocode-parameters export-jpeg qq_desktoptemplatedir = $(appdir) qq_desktoptemplate_DATA = template.desktop
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/export-jpeg/Makefile.am Sun Oct 14 12:40:03 2018 +0100 @@ -0,0 +1,9 @@ +dist_gq_bin_SCRIPTS = geeqie-export-jpeg + +gq_desktopdir = $(appdir)/applications +gq_desktop_in_files = export-jpeg.desktop.in +gq_desktop_DATA = $(gq_desktop_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + +EXTRA_DIST = $(gq_desktop_in_files) +CLEANFILES = $(gq_desktop_DATA)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/export-jpeg/export-jpeg.desktop.in Sun Oct 14 12:40:03 2018 +0100 @@ -0,0 +1,19 @@ +[Desktop Entry] +Version=1.0 +Type=Application +_Name=Export jpeg + +Exec=geeqie-export-jpeg %f + +# show only if these are installed +#TryExec=exiv2 +#TryExec=jpgicc + +# Desktop files that are usable only in Geeqie should be marked like this: +Categories=X-Geeqie; +OnlyShowIn=X-Geeqie; + +# It can be made verbose +#X-Geeqie-Verbose=true + +Icon=geeqie
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/export-jpeg/geeqie-export-jpeg Sun Oct 14 12:40:03 2018 +0100 @@ -0,0 +1,80 @@ +#!/bin/bash + +# Extract emdedded jpegs from a raw file: +# +# Display a list of the embedded files +# Extract the selected image to a tmp folder +# If jpgicc is installed, correct for currently selected rendering intent +# and store in a new file +# Set Geeqie focus to the newly generated image + +count=$(exiv2 -pp "$1" | wc -l) + +if [[ $count -eq 0 ]] +then + zenity --info --width=300 --height=100 --text="Export jpeg from raw file\n\nFile contains no embedded images" --title="Geeqie export jpeg" 2>/dev/null + exit +fi + +if ! [ -x "$(command -v exiv2)" ] +then + zenity --info --width=300 --height=100 --text="Export jpeg from raw file\n\nexiv2 is not installed" --title="Geeqie export jpeg" 2>/dev/null + exit 1 +fi + +if ! [ -x "$(command -v jpgicc)" ] +then + zenity --info --width=300 --height=100 --text="Export jpeg from raw file\n\njpgicc is not installed\ncolor corrections will not be made\nYou may install via liblcms2-utils" --title="Geeqie export jpeg" 2>/dev/null +fi + +list=$(exiv2 -pp "$1") +readarray -t split_list <<<"$list" + +image_list="" +n=1 + +for image in "${split_list[@]}" +do + if [[ $n -eq $count ]] + then + image_list="$image_list"$'TRUE\n'"$image"$'\n'"$n" + else + image_list="$image_list"$'FALSE\n'"$image"$'\n'"$n"$'\n' + fi + n=$((n+1)) +done + +image_selected=$(echo "$image_list" | zenity --width=500 --height=250 --title="Geeqie export jpeg" --list --text "Select embedded image" --radiolist --column "Select" --column "Image" --column "n" --hide-column=3 --print-column=3 2>/dev/null) + +if [[ ! -z "$image_selected" ]] +then + tmpdir=$(mktemp --tmpdir --directory geeqie_export_jpeg_XXXXXX) + + exiv2 -ep"$image_selected" "$1" --location "$tmpdir" + + render_str=$(geeqie --remote --get-render-intent) + + case $render_str in + "Perceptual" ) + render_key=0;; + "Relative Colorimetric" ) + render_key=1;; + "Saturation" ) + render_key=2;; + "Absolute Colorimetric" ) + render_key=3;; + esac + + filename=$(basename "$tmpdir/"* ".jpg") + if [ -x "$(command -v jpgicc)" ] + then + filename_ri="$tmpdir/""$filename""-ri.jpg" + jpgicc -t $render_key "$tmpdir/""$filename"".jpg" "$filename_ri" + + rm "$tmpdir/""$filename"".jpg" + + geeqie --remote view:"$filename_ri" + else + geeqie --remote view:"$tmpdir/""$filename"".jpg" + fi +fi
--- a/src/remote.c Sun Oct 14 10:39:17 2018 +0100 +++ b/src/remote.c Sun Oct 14 12:40:03 2018 +0100 @@ -718,6 +718,35 @@ } } +static void gr_render_intent(const gchar *text, GIOChannel *channel, gpointer data) +{ + gchar *render_intent; + + switch (options->color_profile.render_intent) + { + case 0: + render_intent = g_strdup("Perceptual"); + break; + case 1: + render_intent = g_strdup("Relative Colorimetric"); + break; + case 2: + render_intent = g_strdup("Saturation"); + break; + case 3: + render_intent = g_strdup("Absolute Colorimetric"); + break; + default: + render_intent = g_strdup("none"); + break; + } + + g_io_channel_write_chars(channel, render_intent, -1, NULL, NULL); + g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); + + g_free(render_intent); +} + static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data) { if (!layout_valid(&lw_id)) return; @@ -910,6 +939,7 @@ { NULL, "--tell", gr_file_tell, FALSE, FALSE, NULL, N_("print filename of current image") }, { NULL, "--pixel-info", gr_pixel_info, FALSE, FALSE, NULL, N_("print pixel info of mouse pointer on current image") }, { NULL, "--get-rectangle", gr_rectangle, FALSE, FALSE, NULL, N_("get rectangle co-ordinates") }, + { NULL, "--get-render-intent", gr_render_intent, FALSE, FALSE, NULL, N_("get render intent") }, { NULL, "view:", gr_file_view, TRUE, FALSE, N_("<FILE>"), N_("open FILE in new window") }, { NULL, "--list-clear", gr_list_clear, FALSE, FALSE, NULL, N_("clear command line collection list") }, { NULL, "--list-add:", gr_list_add, TRUE, FALSE, N_("<FILE>"), N_("add FILE to command line collection list") },
--- a/web/geeqie-install-debian.sh Sun Oct 14 10:39:17 2018 +0100 +++ b/web/geeqie-install-debian.sh Sun Oct 14 12:40:03 2018 +0100 @@ -1,5 +1,5 @@ #!/bin/bash -version="2018-08-20" +version="2018-10-14" description=$' Geeqie is an image viewer. This script will download, compile, and install Geeqie on Debian-based systems. @@ -51,6 +51,10 @@ "imagemagick" "ufraw (for RAW file handling)" "ufraw" +"exiv2 command line (for jpeg export)" +"exiv2" +"jpgicc (for jpeg export color correction)" +"liblcms2-utils" "markdown (for generating README help file)" "markdown" )