changes for FS#145

This commit is contained in:
John Bintz 2010-03-18 21:31:01 -04:00
parent 7f51b1035d
commit 8797b3820e
2 changed files with 115 additions and 102 deletions

View File

@ -1110,6 +1110,8 @@ function cpm_write_thumbnail($input, $target_filename, $do_rebuild = false) {
case CPM_SCALE_NONE: case CPM_SCALE_NONE:
return null; return null;
case CPM_SCALE_IMAGEMAGICK: case CPM_SCALE_IMAGEMAGICK:
$original_size = getimagesize($input);
$unique_colors = exec("identify -format '%k' '${input}'"); $unique_colors = exec("identify -format '%k' '${input}'");
if (empty($unique_colors)) { $unique_colors = 256; } if (empty($unique_colors)) { $unique_colors = 256; }
@ -1119,6 +1121,7 @@ function cpm_write_thumbnail($input, $target_filename, $do_rebuild = false) {
? $cpm_config->properties["${type}_comic_width"] ? $cpm_config->properties["${type}_comic_width"]
: $cpm_config->properties['archive_comic_width']; : $cpm_config->properties['archive_comic_width'];
if ($width_to_use < $original_size[0]) {
$command = array("convert", $command = array("convert",
"\"${input}\"", "\"${input}\"",
"-filter Lanczos", "-filter Lanczos",
@ -1156,6 +1159,9 @@ function cpm_write_thumbnail($input, $target_filename, $do_rebuild = false) {
@chmod($target, CPM_FILE_UPLOAD_CHMOD); @chmod($target, CPM_FILE_UPLOAD_CHMOD);
$files_created_in_operation[] = $target; $files_created_in_operation[] = $target;
} }
} else {
copy($input, $target);
}
} }
return ($ok) ? $files_created_in_operation :false ; return ($ok) ? $files_created_in_operation :false ;
@ -1197,6 +1203,7 @@ function cpm_write_thumbnail($input, $target_filename, $do_rebuild = false) {
? $cpm_config->properties["${type}_comic_width"] ? $cpm_config->properties["${type}_comic_width"]
: $cpm_config->properties['archive_comic_width']; : $cpm_config->properties['archive_comic_width'];
if ($width_to_use < $width) {
$archive_comic_height = (int)(($width_to_use * $height) / $width); $archive_comic_height = (int)(($width_to_use * $height) / $width);
$pathinfo = pathinfo($input); $pathinfo = pathinfo($input);
@ -1277,6 +1284,9 @@ function cpm_write_thumbnail($input, $target_filename, $do_rebuild = false) {
return false; return false;
} }
} }
} else {
copy($input, $target);
}
if (!file_exists($target)) { if (!file_exists($target)) {
$ok = false; $ok = false;

View File

@ -173,9 +173,12 @@ function cpm_build_comic_uri($filename, $base_dir = null) {
function cpm_breakdown_comic_filename($filename, $allow_override = false) { function cpm_breakdown_comic_filename($filename, $allow_override = false) {
$pattern = CPM_DATE_FORMAT; $pattern = CPM_DATE_FORMAT;
if ($allow_override !== false) { if ($allow_override !== false) {
if (is_string($allow_override)) {
$pattern = $allow_override; $pattern = $allow_override;
} else {
if (isset($_POST['upload-date-format']) && !empty($_POST['upload-date-format'])) { $pattern = $_POST['upload-date-format']; } if (isset($_POST['upload-date-format']) && !empty($_POST['upload-date-format'])) { $pattern = $_POST['upload-date-format']; }
} }
}
foreach (array('[0-9]{4}', '[0-9]{2}') as $year_pattern) { foreach (array('[0-9]{4}', '[0-9]{2}') as $year_pattern) {
$new_pattern = cpm_transform_date_string($pattern, array("Y" => $year_pattern, $new_pattern = cpm_transform_date_string($pattern, array("Y" => $year_pattern,