[add] Support using the GIMP to import/flatten its native .XCF files.

This commit is contained in:
Solomon Peachy 2010-08-05 15:40:31 -04:00
parent 0c047f1d44
commit b5f73c2f13
8 changed files with 63 additions and 15 deletions

View File

@ -32,6 +32,7 @@ For further information about Photo Organizer, see its web site at:
[fix] Fix duplicate IPTC location creation. [#433]
[fix] Deleteing a photo version updates the memcache properly.
[fix] Import/Handle non-recognized file types as additional versions.
[add] Support using The GIMP to import/flatten its native .xcf format.
2.37-rc2 (October 13, 2009)

View File

@ -432,7 +432,7 @@ if ($result && $set_generate_images == 't') {
/* RAW Decode */
if ($result) {
$real_orig_name = $original_name;
$temporary_ppm_file = import_raw_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
$temporary_ppm_file = import_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
if ($temporary_ppm_file) {
$original_name = $temporary_ppm_file;
}

View File

@ -250,7 +250,7 @@ if ($transform_request && ($transform != "")) {
/* RAW Decode */
if ($retval) {
$temporary_ppm_file = import_raw_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
$temporary_ppm_file = import_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
if ($temporary_ppm_file) {
$original_name = $temporary_ppm_file;
}

View File

@ -99,6 +99,9 @@ $use_gm = FALSE;
// Dave Coffin's raw image decoder
$sys_dcraw = "/usr/local/bin/dcraw";
// Path to The GIMP
$sys_gimp = "/usr/bin/gimp";
// exiftool utility
$sys_exiftool = "/usr/bin/exiftool";

View File

@ -715,7 +715,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
}
}
function import_raw_decode_dcraw($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
function import_decode_dcraw($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
global $sys_dcraw;
global $tmp_volume_path;
global $strings;
@ -777,7 +777,7 @@ function import_raw_decode_dcraw($input_file_name, $camera_input_profile, &$imag
}
}
function import_raw_decode_exiftool($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
function import_decode_exiftool($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
global $sys_exiftool;
global $tmp_volume_path;
global $strings;
@ -819,7 +819,46 @@ function import_raw_decode_exiftool($input_file_name, $camera_input_profile, &$i
}
}
function import_raw_decode_ufraw($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
function import_decode_gimp($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
global $sys_gimp;
global $tmp_volume_path;
global $strings;
if (!is_executable($sys_gimp))
return FALSE;
$temporary_file_name = tempnam($tmp_volume_path, "po");
unlink($temporary_file_name);
$temporary_file_name = $temporary_file_name . ".jpg";
$output .= "<li>".sprintf($strings['import_decoding_raw_using'], 'The GIMP')." ... ";
$script_fu = "
(let*((in-name \"$input_file_name\")
(out-name \"$temporary_file_name\")
(img (car (gimp-xcf-load 0 in-name in-name)))
(layer (car (gimp-image-flatten img))))
(file-jpeg-save 1 img layer out-name out-name 1.0 0.0 0 0 \"Temporary scratch file\" 0 0 0 1 )
(gimp-image-delete img)
(gimp-quit 0))
";
$cmdline = "$sys_gimp -i -s -d -c -b '$script_fu'";
system($cmdline , $retval_decoding);
if ($retval_decoding) {
$output .= "<font color=\"red\">".$strings['generic_failed'].".</font></li>\n";
$output .= "<li><pre>$cmdline</pre></li>\n";
return FALSE;
} else {
$output .= $strings['generic_done'].".</li>\n";
return $temporary_file_name;
}
}
function import_decode_ufraw($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
// global $icc_profiles;
global $sys_ufraw;
global $tmp_volume_path;
@ -903,7 +942,7 @@ function import_raw_decode_ufraw($input_file_name, $camera_input_profile, &$imag
}
}
function import_raw_decode_dcm2pnm($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
function import_decode_dcm2pnm($input_file_name, $camera_input_profile, &$image_data, $index, &$output) {
global $sys_dcm2pnm;
global $tmp_volume_path;
global $strings;
@ -941,7 +980,7 @@ function import_raw_decode_dcm2pnm($input_file_name, $camera_input_profile, &$im
}
}
function import_raw_decode($input_file_name, $decoder, $camera_input_profile, &$image_data, $index, &$output) {
function import_decode($input_file_name, $decoder, $camera_input_profile, &$image_data, $index, &$output) {
global $icc_profiles;
if (($camera_input_profile == FALSE) ||
@ -955,7 +994,7 @@ function import_raw_decode($input_file_name, $decoder, $camera_input_profile, &$
/* Figure out if we have an embedded preview image to extract */
if ($image_data['jpgfromraw']) {
/* This extracts the embedded image to a temporary file */
$image_data['jpgfromraw'] = import_raw_decode_exiftool($input_file_name, $camera_input_profile, $image_data, $index, $output);
$image_data['jpgfromraw'] = import_decode_exiftool($input_file_name, $camera_input_profile, $image_data, $index, $output);
}
$res = FALSE;
@ -963,13 +1002,15 @@ function import_raw_decode($input_file_name, $decoder, $camera_input_profile, &$
foreach ($decoders as $decoder) {
$decoder = trim($decoder);
if ($decoder == "dcraw") {
$res = import_raw_decode_dcraw($input_file_name, $camera_input_profile, $image_data, $index, $output);
$res = import_decode_dcraw($input_file_name, $camera_input_profile, $image_data, $index, $output);
} else if ($decoder == "exiftool") {
$res = import_raw_decode_exiftool($input_file_name, $camera_input_profile, $image_data, $index, $output);
$res = import_decode_exiftool($input_file_name, $camera_input_profile, $image_data, $index, $output);
} else if ($decoder == "ufraw") {
$res = import_raw_decode_ufraw($input_file_name, $camera_input_profile, $image_data, $index, $output);
$res = import_decode_ufraw($input_file_name, $camera_input_profile, $image_data, $index, $output);
} else if ($decoder == "dcm2pnm") {
$res = import_raw_decode_dcm2pnm($input_file_name, $camera_input_profile, $image_data, $index, $output);
$res = import_decode_dcm2pnm($input_file_name, $camera_input_profile, $image_data, $index, $output);
} else if ($decoder == "gimp") {
$res = import_decode_gimp($input_file_name, $camera_input_profile, $image_data, $index, $output);
} else {
$res = FALSE;
}
@ -1151,7 +1192,7 @@ function import_orig_file(&$image_data, $index, $hires_name,
$output .= $strings['generic_done']."</li>\n";
/* Raw Decode */
$temporary_ppm_file = import_raw_decode($image_data['file'][$index]['name_tmp'], $decoder, $image_data['camera_input_profile'], $image_data, $index, $output);
$temporary_ppm_file = import_decode($image_data['file'][$index]['name_tmp'], $decoder, $image_data['camera_input_profile'], $image_data, $index, $output);
if ($temporary_ppm_file) {
unlink($image_data['file'][$index]['name_tmp']);
$image_data['file'][$index]['name_tmp'] = $temporary_ppm_file;

View File

@ -151,7 +151,7 @@ $mime_type = array (
"x3f" => array ("page" => "", "decoder" => "$raw_decoder", "name" => "Sigma raw Image"),
"xbm" => array ("page" => "", "decoder" => "", "name" => "X Windows system bitmap (black and white)"),
"xc" => array ("page" => "", "decoder" => "", "name" => "Constant image uniform color"),
"xcf" => array ("page" => "[0]", "decoder" => "", "name" => "GIMP image"),
"xcf" => array ("page" => "[0]", "decoder" => "gimp", "name" => "GIMP image"),
"xpm" => array ("page" => "", "decoder" => "", "name" => "X Windows system pixmap (color)"),
"xv" => array ("page" => "[0]", "decoder" => "", "name" => "Khoros Visualization image"),
"xmp" => array ("page" => "[0]", "decoder" => "", "name" => "eXtensible Metadata Platform"),

View File

@ -986,6 +986,9 @@ if (!is_executable($sys_exiftool)) {
if (!is_executable($sys_dcraw)) {
print "<h4>The <i>dcraw</i> utility is not installed at $sys_dcraw. This tool is required if you wish to work with RAW images, although ExifTool can be used in some circumstances. If it is installed, please ensure the <i>\$sys_dcraw</i> setting is correct.</h4>\n";
}
if (!is_executable($sys_gimp)) {
print "<h4>The <i>GIMP</i> is not installed at $sys_gimp. This is required if you wish to work with The GIMP's native .XCF file format. If it is installed, please ensure the <i>\$sys_gimp</i> setting is correct.</h4>\n";
}
if (!is_executable($sys_ps2pdf)) {
print "<h4>The <i>ps2pdf</i> utility is not installed at $sys_ps2pdf. Without this tool you cannot export to PDF. If it is installed, please ensure the <i>\$sys_ps2pdf</i> setting is correct.</h4>\n";
}

View File

@ -303,7 +303,7 @@ if ($move_f_request && ($destination_folder != "")) {
/* RAW Decode */
if ($retval) {
$temporary_ppm_file = import_raw_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
$temporary_ppm_file = import_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
if ($temporary_ppm_file) {
$original_name = $temporary_ppm_file;
}