summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-07-22 20:13:53 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-07-22 20:13:53 -0400
commitee290811ec7a0897b80c527747ec6b8a4be6aba9 (patch)
tree0889e621f34814e442e819532cb0f3d97b29624f
parent41649beae43eaecd885a40c9d6166be303817075 (diff)
downloadpo-ee290811ec7a0897b80c527747ec6b8a4be6aba9.tar.gz
po-ee290811ec7a0897b80c527747ec6b8a4be6aba9.tar.bz2
po-ee290811ec7a0897b80c527747ec6b8a4be6aba9.zip
[fix] Start using unique SHA1s for scaled filenames on disk.
-rw-r--r--CHANGES4
-rw-r--r--src/bulk.update.php44
-rw-r--r--src/include/import.php150
3 files changed, 100 insertions, 98 deletions
diff --git a/CHANGES b/CHANGES
index cca4e68..1706d10 100644
--- a/CHANGES
+++ b/CHANGES
@@ -42,8 +42,10 @@ v2.38 (Unreleased)
[misc] Don't display the 'spool' on the main page
[fix] Fix some PHP7-related warnings
[fix] Fix XSS issue on the login page
- [misc] Directly store the 'iso' value instead of an enumerated list.
+ [misc] Directly store the 'iso' value instead of an enumerated list
[fix] PHP7-related error when importing images with an XMP/RDF 'Subject' tag
+ [fix] Use hash of various parameters for scaled image filenames
+
v2.37.1 (December 3, 2012)
[misc] Pretty image URLs now include an extension.
diff --git a/src/bulk.update.php b/src/bulk.update.php
index 1edb367..7f74819 100644
--- a/src/bulk.update.php
+++ b/src/bulk.update.php
@@ -239,7 +239,7 @@ switch ($type) {
}
$sql_selector = " p.identifier in( select photo from album_content a where $sql_selector) ";
-
+
break;
case 'spool':
$sql_selector = " p.identifier in( select photo from album_content where album = $po_user[spool_album])";
@@ -293,7 +293,7 @@ if ($result && $update_photo_tech_sql != "") {
$query = "update photo_tech set
$update_photo_tech_sql
where photo in (select identifier from photo p where $sql_selector)";
-
+
// print "<li><pre>$query</pre></li>";
$result = pg_query($database,$query);
@@ -338,9 +338,9 @@ if ($result) {
$keyword = trim($keyword);
if ($keyword == "") continue;
$keyword = pg_escape_string($keyword);
-
+
$query = "delete from photo_keywords where keyword = '$keyword' and photo in (select p.identifier from photo p where $sql_selector)";
-
+
$result = pg_query($database, $query);
}
}
@@ -369,8 +369,8 @@ if ($result && $set_generate_images == 't') {
$counter = 0;
$query = "
- select get_image_path(v.identifier, 0) as original_path,
- title, p.identifier as photo, colorspace,
+ select get_image_path(v.identifier, 0) as original_path,
+ title, p.identifier as photo, colorspace,
orientation, v.identifier as version
from photo p, photo_version v
where p.identifier = v.photo
@@ -379,10 +379,10 @@ if ($result && $set_generate_images == 't') {
$photo = pg_query($database, $query);
// print "<pre>$query</pre>";
$num_of_photos = pg_num_rows($photo);
-
+
for ($counter = 0; $counter < $num_of_photos; $counter++) {
$photo_data = pg_fetch_assoc($photo, $counter);
-
+
if (($current_volume = get_current_volume($database, FALSE)) == FALSE) {
print err_str($strings['errors_failed_volume']);
break;
@@ -400,25 +400,23 @@ if ($result && $set_generate_images == 't') {
$cleanup_files = array();
pg_query($database, "begin");
-
- $next_index = pg_fetch_row(pg_query($database, "select nextval('photo_id_sequence')"));
$camera_profile = pg_fetch_row(pg_query($database, "
- select raw_icc_profile
+ select raw_icc_profile
from photo_tech, camera, camera_type
where photo_tech.photo = $photo_data[photo]
and photo_tech.camera = camera.identifier
and camera.type = camera_type.identifier"));
- $orientation = orientation_to_xform($database, $photo_data['orientation']);
+ $orientation = orientation_to_xform($database, $photo_data['orientation']);
$original_name = $image_repository_path ."/". $photo_data['original_path'];
$original_file_type = strtolower(substr($original_name, strrpos($original_name, ".") + 1));
$multi_page_parameter = $mime_type[$original_file_type]['page'];
$decoder = $mime_type[$original_file_type]['decoder'];
-
+
print "<li>".$strings['tools_regenerating_images']. emit_a(generate_link('photo', $photo_data['photo'], array('ver'=>$photo_data['version'])), "# $photo_data[photo]:$photo_data[version]");
- print "<ul>";
+ print "<ul>";
$index = 0;
$image_data = array();
@@ -436,47 +434,47 @@ if ($result && $set_generate_images == 't') {
$temporary_ppm_file = import_decode($original_name, $decoder, $camera_profile[0], $image_data, $index, $output);
if ($temporary_ppm_file) {
$original_name = $temporary_ppm_file;
- }
+ }
}
/* Generate scaled images */
if ($result) {
- $result = import_generate_all_scaled($original_name, $multi_page_parameter, $original_name, $database, $photo_data['version'], '', '', $current_volume, $next_index[0], $cleanup_files, $real_orig_name, $image_data, $index, $output);
+ $result = import_generate_all_scaled($original_name, $multi_page_parameter, $original_name, $database, $photo_data['version'], '', '', $current_volume, $photo_data['photo'], $cleanup_files, $real_orig_name, $image_data, $index, $output);
}
if ($temporary_ppm_file) {
unlink($temporary_ppm_file);
}
- // XXX -- Kick the date_changed fields via the DB drigger
+ // XXX -- Kick the date_changed fields via the DB trigger
if ($result) {
$result = pg_query($database, "update photo_version set date_changed = now() where identifier = $photo_data[version] ");
}
-
+
/* Delete the old files! */
if ($result) {
foreach ($old_files as $file => $path) {
- $retval = pg_query($database, "delete from files where identifier = $file");
+ $retval = pg_query($database, "delete from files where identifier = $file");
}
}
if ($result) {
$err = error_reporting(0);
foreach ($old_files as $file => $path) {
- unlink("$image_repository_path/$path");
+ unlink("$image_repository_path/$path");
}
error_reporting($err);
}
-
+
print $output;
print "</ul></li>";
-
+
if ($result) {
pg_query($database, "commit");
} else {
pg_query($database, "rollback");
$err = error_reporting(0);
foreach ($cleanup_files as $file) {
- unlink($file);
+ unlink($file);
}
error_reporting($err);
break;
diff --git a/src/include/import.php b/src/include/import.php
index 06307a9..440c47e 100644
--- a/src/include/import.php
+++ b/src/include/import.php
@@ -34,7 +34,7 @@ function check_utf8($in_str) {
function count_storage_space_by_user($database, $user_id) {
$file_sizes = pg_query($database, "
- select sum(filesize)
+ select sum(filesize)
from files, photo_version, photo
where photo.users = $user_id
and photo.identifier = photo_version.photo
@@ -66,7 +66,7 @@ function dirsize($database, $directory) {
function get_current_volume($database, $image_file) {
global $image_repository_path;
global $po_options_default;
-
+
$curr_volume = readlink($image_repository_path."/current");
$new_volume = $curr_volume;
@@ -89,7 +89,7 @@ function get_current_volume($database, $image_file) {
if (($dir_size['size'] + $image_size/1048576) < $po_options_default['volume_max_size'])
break;
- if ($po_options_default['volume_max_count'] &&
+ if ($po_options_default['volume_max_count'] &&
($po_options_default['volume_max_count'] < $dir_size['files']))
break;
@@ -313,7 +313,7 @@ function photo_import_worker($database, $userid = FALSE, $background = TRUE) {
$master = -1;
}
- /* upload all other photos as versions */
+ /* upload all other photos as versions */
for ($index = 0; $index < $image_data['num_of_files']; $index++) {
if ($index === $master) continue;
if ($image_data['file'][$index]['master'] != 't') {
@@ -398,7 +398,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
} else {
$photo_id = $master_photo_id;
}
-
+
$next_version = pg_fetch_row(pg_query($database, "select nextval('photo_version_id_sequence')"));
$version_id = $next_version[0];
@@ -483,7 +483,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
/* Figure out orientation and necessary transforms */
if ($result) {
- $orientation = orientation_id_from_string($database, $image_data['file'][$index]["orientation"]);
+ $orientation = orientation_id_from_string($database, $image_data['file'][$index]["orientation"]);
$image_data['file'][$index]["orientation_xform"] = orientation_to_xform($database, $orientation);
if ($image_data['file'][$index]['colorspace'] == "") {
$image_data['file'][$index]['colorspace'] = "1";
@@ -504,7 +504,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
supplemental_category, web_statement, store_url, comments)
values ($photo_id, '$po_user[id]', '$image_data[folder]', $image_data[location],
'$image_data[caption]', $image_data[date_of_exposure], '$image_data[access_rights]', '$image_data[copyright]',
- 0, '$image_data[hide_original]', '$image_data[author]', '$image_data[title]',
+ 0, '$image_data[hide_original]', '$image_data[author]', '$image_data[title]',
'$image_data[caption_writer]', '$image_data[category]', '$image_data[credit]', '$image_data[source]',
'$image_data[headline]', '$image_data[instructions]', '$image_data[transmission_reference]',
'$image_data[supplemental_category]', '$image_data[web_statement]', '$image_data[store_url]', '$image_data[remark]')";
@@ -521,11 +521,11 @@ function photo_import_single($database, $index, &$image_data, &$output) {
}
$original_name = pg_escape_string($original_name);
$comment = $image_data['file'][$index]['remark'];
- $orientation = orientation_id_from_string($database, $image_data['file'][$index]["orientation"]);
+ $orientation = orientation_id_from_string($database, $image_data['file'][$index]["orientation"]);
$query = "insert into photo_version(identifier, key, photo, master, original_image_name, comment, colorspace, orientation)
values ($version_id, '$key[0]', $photo_id, '$master', '$original_name', '$comment', ".$image_data['file'][$index]['colorspace']." , $orientation )";
$result = pg_query($database, $query);
- }
+ }
/* Update album records to point to new version if desired */
if ($master_photo_id && $result && ($old_master != $version_id)) {
@@ -541,8 +541,8 @@ function photo_import_single($database, $index, &$image_data, &$output) {
$keyword = trim($keyword);
if ($keyword == "") continue;
$keyword = pg_escape_string($keyword);
-
- $query = "insert into photo_keywords (photo, keyword)
+
+ $query = "insert into photo_keywords (photo, keyword)
values ($photo_id, '$keyword')";
$result = pg_query($database, $query);
}
@@ -585,7 +585,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
}
}
- /* Commit the photo record to the DB. All that's left are the
+ /* Commit the photo record to the DB. All that's left are the
image generation and insertions for each size into the DB. */
if ($result) {
pg_query($database, "commit");
@@ -603,7 +603,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
/* Deal with original file! */
if ($result) {
$cleanup_files[] = $hires_name;
- $result = import_orig_file($image_data, $index, $hires_name,
+ $result = import_orig_file($image_data, $index, $hires_name,
$decoder, $database, $version_id, $output);
}
@@ -651,7 +651,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
foreach ($cleanup_files as $file) {
unlink($file);
}
- error_reporting($err);
+ error_reporting($err);
if ($master_photo_id) {
/* Nuke the stillborn version only! */
@@ -674,7 +674,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
/* Transfer metadata over to preview image */
$output .= "<li>";
- transfer_metadata($hires_name,
+ transfer_metadata($hires_name,
$image_data['jpgfromraw'], FALSE, $image_data, $output);
$output .= "</li>";
@@ -690,7 +690,7 @@ function photo_import_single($database, $index, &$image_data, &$output) {
$image_data['replace_existing'] = 'f';
$image_data['user'] = $po_user['id'];
}
-
+
/* attempt to remove the directory that the file was in. */
{
$path = dirname($image_data['file'][$index]['name']);
@@ -710,14 +710,14 @@ function import_decode_dcraw($input_file_name, $camera_input_profile, &$image_da
global $sys_dcraw;
global $tmp_volume_path;
global $strings;
-
+
$po_options = $image_data['po_options'];
$temporary_file_name = tempnam($tmp_volume_path, "po");
unlink($temporary_file_name);
$temporary_file_name = $temporary_file_name . ".ppm";
- if (!is_executable($sys_dcraw))
+ if (!is_executable($sys_dcraw))
return FALSE;
$output .= "<li>".sprintf($strings['import_decoding_raw_using'], 'dcraw')." ... ";
@@ -757,7 +757,7 @@ function import_decode_dcraw($input_file_name, $camera_input_profile, &$image_da
if ($retval_decoding) {
$output .= "<font color=\"red\">".$strings['generic_failed'].".</font></li>\n";
- $output .= "<li><pre>$cmdline</pre></li>\n";
+ $output .= "<li><pre>$cmdline</pre></li>\n";
return FALSE;
} else {
/* dcraw automatically rotates images */
@@ -779,7 +779,7 @@ function import_decode_exiftool($input_file_name, $camera_input_profile, &$image
/* If we don't have a RAW preview image, we're SOL here */
if (!$image_data['jpgfromraw'])
return FALSE;
-
+
/* If we're already extracted the image, just use that one. */
if (file_exists($image_data['jpgfromraw']))
return $image_data['jpgfromraw'];
@@ -797,9 +797,9 @@ function import_decode_exiftool($input_file_name, $camera_input_profile, &$image
$output .= "<li>".sprintf($strings['import_decoding_raw_using'], 'ExifTool')." ... ";
$cmdline = "$sys_exiftool " . escapeshellarg($input_file_name) . " $options ";
-
+
system($cmdline , $retval_decoding);
-
+
if ($retval_decoding) {
$output .= "<font color=\"red\">".$strings['generic_failed'].".</font></li>\n";
$output .= "<li><pre>$cmdline</pre></li>\n";
@@ -817,7 +817,7 @@ function import_decode_gimp($input_file_name, $camera_input_profile, &$image_dat
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";
@@ -838,9 +838,9 @@ function import_decode_gimp($input_file_name, $camera_input_profile, &$image_dat
putenv("GIMP2_DIRECTORY=$tmp_volume_path/.gimp2");
putenv("DISPLAY=");
$cmdline = "$sys_gimp -n -f -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";
@@ -858,16 +858,16 @@ function import_decode_mplayer($input_file_name, $camera_input_profile, &$image_
if (!is_executable($sys_mplayer))
return FALSE;
-
+
$temporary_file_name = tempnam($tmp_volume_path, "po");
unlink($temporary_file_name);
$output .= "<li>".sprintf($strings['import_decoding_raw_using'], 'mplayer')." ... ";
$cmdline = "$sys_mplayer -quiet -ao null -vo pnm:ppm:outdir='$temporary_file_name' -frames 10 ".escapeshellarg($input_file_name);
-
+
system($cmdline , $retval_decoding);
-
+
if ($retval_decoding) {
$output .= "<font color=\"red\">".$strings['generic_failed'].".</font></li>\n";
$output .= "<li><pre>$cmdline</pre></li>\n";
@@ -880,7 +880,7 @@ function import_decode_mplayer($input_file_name, $camera_input_profile, &$image_
$newname = sprintf("$temporary_file_name/000000%02d.ppm", $i);
if (file_exists($newname)) {
if ($fname === FALSE)
- $fname = $newname;
+ $fname = $newname;
else
unlink($newname);
}
@@ -923,9 +923,9 @@ function import_decode_ufraw($input_file_name, $camera_input_profile, &$image_da
$exposure = "auto"; // exposure compensation
$linearity = $po_options['ufraw_gamma_linearity'];
- $gamma = $po_options['ufraw_gamma'];
+ $gamma = $po_options['ufraw_gamma'];
- if (($curve == "camera") || ($curve == "linear") || ($curve=="custom")) {
+ if (($curve == "camera") || ($curve == "linear") || ($curve=="custom")) {
$curve = "--base-curve=$curve";
} else {
$curve = "--base-curve-file=$curve";
@@ -950,14 +950,14 @@ function import_decode_ufraw($input_file_name, $camera_input_profile, &$image_da
$options .= " --wb=camera";
}
switch ($po_options['raw_bitdepth']) {
- case 24:
+ case 24:
$options .= " --out-type=ppm8";
break;
case 48:
$options .= " --out-type=ppm16";
}
- $cmdline = "$sys_ufraw $options --silent --output=$temporary_file_name " . escapeshellarg($input_file_name);
+ $cmdline = "$sys_ufraw $options --silent --output=$temporary_file_name " . escapeshellarg($input_file_name);
system($cmdline, $retval_decoding);
@@ -992,7 +992,7 @@ function import_decode_dcm2pnm($input_file_name, $camera_input_profile, &$image_
$options = "";
switch ($po_options['raw_bitdepth']) {
- case 24:
+ case 24:
$options = $options . " --write-8-bit-pnm";
break;
case 48:
@@ -1017,14 +1017,14 @@ function import_decode_darktable($input_file_name, $camera_input_profile, &$imag
global $sys_darktable;
global $tmp_volume_path;
global $strings;
-
+
$po_options = $image_data['po_options'];
$temporary_file_name = tempnam($tmp_volume_path, "po");
unlink($temporary_file_name);
$temporary_file_name = $temporary_file_name . ".ppm";
- if (!is_executable($sys_darktable))
+ if (!is_executable($sys_darktable))
return FALSE;
$output .= "<li>".sprintf($strings['import_decoding_raw_using'], 'darktable')." ... ";
@@ -1066,7 +1066,7 @@ function import_decode_darktable($input_file_name, $camera_input_profile, &$imag
if ($retval_decoding) {
$output .= "<font color=\"red\">".$strings['generic_failed'].".</font></li>\n";
- $output .= "<li><pre>$cmdline</pre></li>\n";
+ $output .= "<li><pre>$cmdline</pre></li>\n";
return FALSE;
} else {
/* dcraw automatically rotates images */
@@ -1087,12 +1087,12 @@ function import_decode($input_file_name, $decoder, $camera_input_profile, &$imag
} else {
$camera_input_profile = $icc_profiles[$camera_input_profile]['file'];
}
-
+
/* 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_decode_exiftool($input_file_name, $camera_input_profile, $image_data, $index, $output);
- }
+ }
$res = FALSE;
$decoders = explode(",", $decoder);
@@ -1114,7 +1114,7 @@ function import_decode($input_file_name, $decoder, $camera_input_profile, &$imag
$res = import_decode_mplayer($input_file_name, $camera_input_profile, $image_data, $index, $output);
} else {
$res = FALSE;
- }
+ }
if ($res !== FALSE) break;
}
@@ -1122,11 +1122,11 @@ function import_decode($input_file_name, $decoder, $camera_input_profile, &$imag
return $res;
}
-function import_generate_scaled($input_file_name, $output_file_name,
- $multi_page_parameter, $size_key,
+function import_generate_scaled($input_file_name, $output_file_name,
+ $multi_page_parameter, $size_key,
$watermark, $original_file_name,
- $database, $version_id, $params,
- $comments, $master_file_name,
+ $database, $version_id, $params,
+ $comments, $master_file_name,
&$image_data, $index, &$output)
{
global $sys_convert;
@@ -1135,7 +1135,7 @@ function import_generate_scaled($input_file_name, $output_file_name,
global $use_gm;
global $icc_profiles;
global $strings;
- global $image_repository_path;
+ global $image_repository_path;
$po_options = $image_data['po_options'];
@@ -1187,7 +1187,7 @@ function import_generate_scaled($input_file_name, $output_file_name,
# Ensure we strip all profiles out of the final image..
$im_profile_b .= " +profile icm ";
-
+
$output .= "<li>".$strings['import_generating_'.$size_name] ." ... ";
/* generate preview */
@@ -1207,9 +1207,9 @@ function import_generate_scaled($input_file_name, $output_file_name,
(($po_options[$size_key.'_gamma'] == 1) ? "" : " -gamma " . escapeshellarg($po_options[$size_key.'_gamma'])) .
" -quality " . escapeshellarg($po_options[$size_key.'_quality']) ." ".
escapeshellarg($input_file_name).escapeshellarg($multi_page_parameter) . ' ' .
- ($use_gm ? '' : ' -strip ') .
+ ($use_gm ? '' : ' -strip ') .
escapeshellarg($output_file_name);
-
+
system($cmdline, $retval_image_scaling);
if ($retval_image_scaling) {
@@ -1219,14 +1219,14 @@ function import_generate_scaled($input_file_name, $output_file_name,
} else {
$output .= $strings['generic_done'] . " (". $po_options[$size_key.'_max_size'] ." ".$strings['generic_pixels']. ")</li>\n";
}
-
+
/* Are we supposed to watermark the image? */
if ($watermark) {
/* Fix up the watermark path as needed */
if (substr($po_options['watermark_path'], 0, 1) != '/') {
$po_options['watermark_path'] = "$image_repository_path/$po_options[watermark_path]";
}
-
+
$output .= "<li>".$strings['import_watermarking'] ." ... ";
if ($use_gm) {
@@ -1243,7 +1243,7 @@ function import_generate_scaled($input_file_name, $output_file_name,
escapeshellarg($output_file_name);
system($cmdline, $retval_watermarking);
-
+
if ($retval_watermarking) {
$output .= "<font color=\"red\">".$strings['generic_failed'].".</font></li>\n";
$output .= "<li><pre>$cmdline</pre></li>\n";
@@ -1272,7 +1272,7 @@ function import_generate_scaled($input_file_name, $output_file_name,
/* Copies the original file into its resting place in the repository
and performs a RAW decode if necessary */
-function import_orig_file(&$image_data, $index, $hires_name,
+function import_orig_file(&$image_data, $index, $hires_name,
$decoder, $database, $version_id, &$output) {
global $strings;
global $image_repository_path;
@@ -1305,7 +1305,7 @@ function import_orig_file(&$image_data, $index, $hires_name,
$image_data['file'][$index]["orientation_xform"] = orientation_to_xform($database, $orientation);
/* Copy the original image into the repository */
- $success = import_file($database, $hires_name, $image_repository_path,
+ $success = import_file($database, $hires_name, $image_repository_path,
$version_id, 0, FALSE, '', '');
}
@@ -1314,7 +1314,7 @@ function import_orig_file(&$image_data, $index, $hires_name,
}
/* Inserts a file record into the database. Also fixes permissions */
-function import_file($database, $file_name, $base_path, $version_id,
+function import_file($database, $file_name, $base_path, $version_id,
$size_code, $watermark, $params, $comments)
{
global $query;
@@ -1331,32 +1331,32 @@ function import_file($database, $file_name, $base_path, $version_id,
$image_dimension = array(0, 0);
} else {
$image_dimension = po_get_image_size($file_name);
- }
+ }
$size = filesize($file_name);
$file = substr($file_name, strlen($base_path));
if (substr($file, 0, 1) == '/') {
$file = substr($file, 1);
}
-
- $query = "INSERT INTO files
- (identifier, version, size, x_res, y_res, path, filesize, params, comments, watermark, sha1sum)
- VALUES ((select nextval('files_id_sequence')), $version_id, $size_code,
- $image_dimension[0], $image_dimension[1], '$file',
+
+ $query = "INSERT INTO files
+ (identifier, version, size, x_res, y_res, path, filesize, params, comments, watermark, sha1sum)
+ VALUES ((select nextval('files_id_sequence')), $version_id, $size_code,
+ $image_dimension[0], $image_dimension[1], '$file',
$size, '$params', '$comments', $watermark, '$sha1sum')";
$result = pg_query($database, $query);
return $result;
}
-function import_generate_all_scaled($input_file_name, $multi_page_parameter,
- $original_file_name, $database, $version_id,
- $params, $comments, $current_volume,
- $next_index, &$outfiles,
- $master_file_name, &$image_data,
+function import_generate_all_scaled($input_file_name, $multi_page_parameter,
+ $original_file_name, $database, $version_id,
+ $params, $comments, $current_volume,
+ $photo_id, &$outfiles,
+ $master_file_name, &$image_data,
$index, &$output)
{
global $image_respository_path;
-
+
$po_options = $image_data['po_options'];
$sizes = explode(",", $po_options['scaled_generate']);
@@ -1369,12 +1369,12 @@ function import_generate_all_scaled($input_file_name, $multi_page_parameter,
return TRUE;
}
- $image_data['max_res'] = ($image_dimension[0] > $image_dimension[1]) ? $image_dimension[0] : $image_dimension[1];
+ $image_data['max_res'] = ($image_dimension[0] > $image_dimension[1]) ? $image_dimension[0] : $image_dimension[1];
foreach ($sizes as $size_key) {
$po_options = $image_data['po_options'];
- if ($po_options[$size_key.'_watermark_location'] &&
- $po_options[$size_key.'_watermark_brightness'] &&
+ if ($po_options[$size_key.'_watermark_location'] &&
+ $po_options[$size_key.'_watermark_brightness'] &&
$po_options['watermark_photo']) {
$watermark = $po_options['watermark_photo'];
// generate one watermark and one non-watermark image?
@@ -1382,15 +1382,17 @@ function import_generate_all_scaled($input_file_name, $multi_page_parameter,
$watermark = FALSE;
}
- $output_file_name = "$current_volume/00001/$next_index" . "_$version_id" . "_" . $po_options[$size_key."_sizecode"] . ($watermark? "_wm$watermark" : '') ."_$size_key." . $po_options[$size_key."_format"];
+ $raw = sha1(sprintf("%d %d %d %s %s", time(), $photo_id, $version_id, $po_options[$size_key."_sizecode"], ($watermark? "_wm$watermark" : '')));
+
+ $output_file_name = "$current_volume/00001/$raw" . "." . $po_options[$size_key."_format"];
$outfiles[] = $output_file_name;
- $result = import_generate_scaled($input_file_name, $output_file_name,
- $multi_page_parameter, $size_key,
+ $result = import_generate_scaled($input_file_name, $output_file_name,
+ $multi_page_parameter, $size_key,
$watermark, $original_file_name,
- $database, $version_id, $params,
- $comments, $master_file_name,
+ $database, $version_id, $params,
+ $comments, $master_file_name,
$image_data, $index, $output);
}