fixing images plus
- fix isp image $newSize resizement - fix forcing $newSize with a bang on WinOS - convert some message errors to 2.0 style - whitespace cleanup
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<?php #
|
||||
<?php
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
# Improved by Vladimir Ajgl (vlada@ajgl.cz) 2008-01-26
|
||||
@ -616,7 +616,6 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
if ($size === false) {
|
||||
$size = $serendipity['thumbSize'];
|
||||
}
|
||||
|
||||
if ($size < 1) {
|
||||
return array(0,0);
|
||||
}
|
||||
@ -629,9 +628,8 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
$f = $t[0];
|
||||
$suf = $t[1];
|
||||
|
||||
|
||||
$infile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file;
|
||||
# echo 'From: ' . $infile . '<br />';
|
||||
#echo 'From: ' . $infile . '<br />';
|
||||
if ($is_temporary) {
|
||||
$temppath = dirname($thumbname);
|
||||
if (!is_dir($temppath)) {
|
||||
@ -642,9 +640,9 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
$outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf;
|
||||
}
|
||||
$serendipity['last_outfile'] = $outfile;
|
||||
# echo 'To: ' . $outfile . '<br />';
|
||||
#echo 'To: ' . $outfile . '<br />';
|
||||
|
||||
$fdim = @serendipity_getimagesize($infile, '', $suf);
|
||||
$fdim = @serendipity_getimagesize($infile, '', $suf);
|
||||
if (isset($fdim['noimage'])) {
|
||||
$r = array(0, 0);
|
||||
} else {
|
||||
@ -659,23 +657,28 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
}
|
||||
} else {
|
||||
if (is_array($size)) {
|
||||
$r = $size;
|
||||
if ($fdim[0] > $size['width'] && $fdim[1] > $size['height']) {
|
||||
$r = $size;
|
||||
} else {
|
||||
return array(0,0);
|
||||
}
|
||||
} else {
|
||||
$calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']);
|
||||
$r = array('width' => $calc[0], 'height' => $calc[1]);
|
||||
}
|
||||
$newSize = $r['width'] . 'x' . $r['height'];
|
||||
if ($fdim['mime'] == 'application/pdf') {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile . '[0]') . ' ' . serendipity_escapeshellarg($outfile . '.png');
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile . '[0]') . ' ' . serendipity_escapeshellarg($outfile . '.png');
|
||||
} else {
|
||||
if (!$force_resize && serendipity_ini_bool(ini_get('safe_mode')) === false) {
|
||||
$newSize .= '>'; // Tell imagemagick to not enlarge small images, only works if safe_mode is off (safe_mode turns > in to \>)
|
||||
}
|
||||
$cmd = escapeshellcmd($serendipity['convert'] . ' ' . $serendipity['imagemagick_thumb_parameters']) . ' -antialias -resize ' . serendipity_escapeshellarg($newSize) . '\! ' . serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);
|
||||
$newSize .= '!'; // force the image geometry exactly to given sizes (see https://github.com/s9y/Serendipity/commit/94881ba4c0e3bdd4b5fac510e93977e239171c1c and comments)
|
||||
$cmd = escapeshellcmd($serendipity['convert'] . ' ' . $serendipity['imagemagick_thumb_parameters']) . ' -antialias -resize ' . serendipity_escapeshellarg($newSize) . ' ' . serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);
|
||||
}
|
||||
exec($cmd, $output, $result);
|
||||
if ($result != 0) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
$r = false; // return failure
|
||||
} else {
|
||||
touch($outfile);
|
||||
@ -683,7 +686,6 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
unset($output, $result);
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
@ -719,7 +721,7 @@ function serendipity_scaleImg($id, $width, $height) {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -scale ' . serendipity_escapeshellarg($width . 'x' . $height) . ' ' . serendipity_escapeshellarg($infile) . ' ' . serendipity_escapeshellarg($outfile);
|
||||
exec($cmd, $output, $result);
|
||||
if ( $result != 0 ) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
}
|
||||
unset($output, $result);
|
||||
}
|
||||
@ -766,7 +768,7 @@ function serendipity_rotateImg($id, $degrees) {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -rotate ' . serendipity_escapeshellarg($degrees) . ' ' . serendipity_escapeshellarg($infile) . ' ' . serendipity_escapeshellarg($outfile);
|
||||
exec($cmd, $output, $result);
|
||||
if ( $result != 0 ) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
}
|
||||
unset($output, $result);
|
||||
|
||||
@ -774,7 +776,7 @@ function serendipity_rotateImg($id, $degrees) {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -rotate ' . serendipity_escapeshellarg($degrees) . ' ' . serendipity_escapeshellarg($infileThumb) . ' ' . serendipity_escapeshellarg($outfileThumb);
|
||||
exec($cmd, $output, $result);
|
||||
if ( $result != 0 ) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />'. sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
}
|
||||
unset($output, $result);
|
||||
|
||||
@ -1347,7 +1349,7 @@ function serendipity_resize_image_gd($infilename, $outfilename, $newwidth, $newh
|
||||
|
||||
imagecopyresampled($out, $in, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
@umask(0000);
|
||||
touch($outfilename); // safe_mode requirement
|
||||
touch($outfilename); // safe_mode requirement
|
||||
$func['save']($out, $outfilename, $func['qual']);
|
||||
@chmod($outfilename, 0664);
|
||||
$out = null;
|
||||
@ -2184,19 +2186,19 @@ function serendipity_directoryACL(&$paths, $type = 'read') {
|
||||
if ($granted === false) {
|
||||
// We are not allowed to access this element
|
||||
if ($debug) {
|
||||
echo "<span class='msg_error'>ACL for " . $info['relpath'] . " DENIED.</span>";
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ACL for ' . $info['relpath'] . " DENIED.</span>";
|
||||
}
|
||||
unset($paths[$idx]);
|
||||
} else {
|
||||
if ($debug) {
|
||||
echo "<span class='msg_success'>ACL for " . $info['relpath'] . " granted.</span>";
|
||||
echo '<span class="msg_success"><span class="icon-ok-circled"></span> ACL for ' . $info['relpath'] . " granted.</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($paths) < $startCount) {
|
||||
if ($debug) {
|
||||
echo "<span class='msg_error'>ACL denied all.</span>";
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ACL denied all.</span>';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -3117,14 +3119,14 @@ function &serendipity_getMetaData($file, &$info) {
|
||||
|
||||
static $ExifFields = array(
|
||||
'IFD0' => array(
|
||||
'Make' => array('type' => 'text', 'name' => 'CameraMaker'),
|
||||
'Model' => array('type' => 'text', 'name' => 'CameraModel'),
|
||||
'Orientation' => array('type' => 'or', 'name' => 'Orientation'),
|
||||
'XResolution' => array('type' => 'math', 'name' => 'XResolution'),
|
||||
'YResolution' => array('type' => 'math', 'name' => 'YResolution'),
|
||||
'Software' => array('type' => 'text', 'name' => 'Software'),
|
||||
'DateTime' => array('type' => 'date2', 'name' => 'DateCreated'),
|
||||
'Artist' => array('type' => 'text', 'name' => 'Creator'),
|
||||
'Make' => array('type' => 'text', 'name' => 'CameraMaker'),
|
||||
'Model' => array('type' => 'text', 'name' => 'CameraModel'),
|
||||
'Orientation' => array('type' => 'or', 'name' => 'Orientation'),
|
||||
'XResolution' => array('type' => 'math', 'name' => 'XResolution'),
|
||||
'YResolution' => array('type' => 'math', 'name' => 'YResolution'),
|
||||
'Software' => array('type' => 'text', 'name' => 'Software'),
|
||||
'DateTime' => array('type' => 'date2', 'name' => 'DateCreated'),
|
||||
'Artist' => array('type' => 'text', 'name' => 'Creator'),
|
||||
),
|
||||
|
||||
'EXIF' => array(
|
||||
@ -3147,33 +3149,33 @@ function &serendipity_getMetaData($file, &$info) {
|
||||
);
|
||||
|
||||
static $xmpPatterns = array(
|
||||
'tiff:Orientation' => array('type' => 'or', 'name' => 'Orientation'),
|
||||
'tiff:XResolution' => array('type' => 'math', 'name' => 'XResolution'),
|
||||
'tiff:YResolution' => array('type' => 'math', 'name' => 'YResolution'),
|
||||
'tiff:Make' => array('type' => 'text', 'name' => 'CameraMaker'),
|
||||
'tiff:Model' => array('type' => 'text', 'name' => 'CameraModel'),
|
||||
'xap:ModifyDate' => array('type' => 'date', 'name' => 'DateModified'),
|
||||
'xap:CreatorTool' => array('type' => 'text', 'name' => 'Software'),
|
||||
'xap:CreateDate' => array('type' => 'date', 'name' => 'DateCreated'),
|
||||
'xap:MetadataDate' => array('type' => 'date', 'name' => 'DateMetadata'),
|
||||
'tiff:Orientation' => array('type' => 'or', 'name' => 'Orientation'),
|
||||
'tiff:XResolution' => array('type' => 'math', 'name' => 'XResolution'),
|
||||
'tiff:YResolution' => array('type' => 'math', 'name' => 'YResolution'),
|
||||
'tiff:Make' => array('type' => 'text', 'name' => 'CameraMaker'),
|
||||
'tiff:Model' => array('type' => 'text', 'name' => 'CameraModel'),
|
||||
'xap:ModifyDate' => array('type' => 'date', 'name' => 'DateModified'),
|
||||
'xap:CreatorTool' => array('type' => 'text', 'name' => 'Software'),
|
||||
'xap:CreateDate' => array('type' => 'date', 'name' => 'DateCreated'),
|
||||
'xap:MetadataDate' => array('type' => 'date', 'name' => 'DateMetadata'),
|
||||
|
||||
'exif:ExposureTime' => array('type' => 'math', 'name' => 'ExposureTime'),
|
||||
'exif:ApertureValue' => array('type' => 'math', 'name' => 'ApertureValue'),
|
||||
'exif:MaxApertureValue' => array('type' => 'math', 'name' => 'MaxApertureValue'),
|
||||
'exif:ISOSpeedRatings' => array('type' => 'text', 'name' => 'ISOSpeedRatings'),
|
||||
'exif:DateTimeOriginal' => array('type' => 'date', 'name' => 'DateCreated'),
|
||||
'exif:MeteringMode' => array('type' => 'text', 'name' => 'MeteringMode'),
|
||||
'exif:FNumber' => array('type' => 'math', 'name' => 'FNumber'),
|
||||
'exif:ExposureProgram' => array('type' => 'text', 'name' => 'ExposureProgram'),
|
||||
'exif:FocalLength' => array('type' => 'math', 'name' => 'FocalLength'),
|
||||
'exif:WhiteBalance' => array('type' => 'text', 'name' => 'WhiteBalance'),
|
||||
'exif:DigitalZoomRatio' => array('type' => 'math', 'name' => 'DigitalZoomRatio'),
|
||||
'exif:FocalLengthIn35mmFilm' => array('type' => 'text', 'name' => 'FocalLengthIn35mmFilm'),
|
||||
'exif:Fired' => array('type' => 'text', 'name' => 'FlashFired'),
|
||||
'exif:RedEyeMode' => array('type' => 'text', 'name' => 'RedEyeMode'),
|
||||
'exif:ExposureTime' => array('type' => 'math', 'name' => 'ExposureTime'),
|
||||
'exif:ApertureValue' => array('type' => 'math', 'name' => 'ApertureValue'),
|
||||
'exif:MaxApertureValue' => array('type' => 'math', 'name' => 'MaxApertureValue'),
|
||||
'exif:ISOSpeedRatings' => array('type' => 'text', 'name' => 'ISOSpeedRatings'),
|
||||
'exif:DateTimeOriginal' => array('type' => 'date', 'name' => 'DateCreated'),
|
||||
'exif:MeteringMode' => array('type' => 'text', 'name' => 'MeteringMode'),
|
||||
'exif:FNumber' => array('type' => 'math', 'name' => 'FNumber'),
|
||||
'exif:ExposureProgram' => array('type' => 'text', 'name' => 'ExposureProgram'),
|
||||
'exif:FocalLength' => array('type' => 'math', 'name' => 'FocalLength'),
|
||||
'exif:WhiteBalance' => array('type' => 'text', 'name' => 'WhiteBalance'),
|
||||
'exif:DigitalZoomRatio' => array('type' => 'math', 'name' => 'DigitalZoomRatio'),
|
||||
'exif:FocalLengthIn35mmFilm' => array('type' => 'text', 'name' => 'FocalLengthIn35mmFilm'),
|
||||
'exif:Fired' => array('type' => 'text', 'name' => 'FlashFired'),
|
||||
'exif:RedEyeMode' => array('type' => 'text', 'name' => 'RedEyeMode'),
|
||||
|
||||
'dc:title' => array('type' => 'rdf', 'name' => 'Title'),
|
||||
'dc:creator' => array('type' => 'rdf', 'name' => 'Creator'),
|
||||
'dc:title' => array('type' => 'rdf', 'name' => 'Title'),
|
||||
'dc:creator' => array('type' => 'rdf', 'name' => 'Creator'),
|
||||
);
|
||||
|
||||
$ret = array();
|
||||
@ -3448,11 +3450,11 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
|
||||
// Forward user to overview (we don't want the user's back button to rename things again)
|
||||
} else {
|
||||
if (!file_exists($oldfile)) {
|
||||
echo '<span class="msg_error">' . ERROR_FILE_NOT_EXISTS . '</span>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . ERROR_FILE_NOT_EXISTS . '</span>';
|
||||
} elseif (file_exists($newfile)) {
|
||||
echo '<span class="msg_error">' . ERROR_FILE_EXISTS . '</span>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . ERROR_FILE_EXISTS . '</span>';
|
||||
} else {
|
||||
echo '<span class="msg_error">' . ERROR_SOMETHING . '</span>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . ERROR_SOMETHING . '</span>';
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -3470,16 +3472,16 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
|
||||
$newfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $newDir . $pick['name'] . (empty($pick['extension']) ? '' : '.' . $pick['extension']);
|
||||
|
||||
$renameValues = array(array(
|
||||
'from' => $oldfile,
|
||||
'to' => $newfile,
|
||||
'thumb' => $serendipity['thumbSuffix'],
|
||||
'fthumb' => $pick['thumbnail_name'],
|
||||
'oldDir' => $oldDir,
|
||||
'newDir' => $newDir,
|
||||
'type' => $type,
|
||||
'item_id'=> $item_id,
|
||||
'file' => $file,
|
||||
'name' => $pick['name']
|
||||
'from' => $oldfile,
|
||||
'to' => $newfile,
|
||||
'thumb' => $serendipity['thumbSuffix'],
|
||||
'fthumb' => $pick['thumbnail_name'],
|
||||
'oldDir' => $oldDir,
|
||||
'newDir' => $newDir,
|
||||
'type' => $type,
|
||||
'item_id' => $item_id,
|
||||
'file' => $file,
|
||||
'name' => $pick['name']
|
||||
));
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_media_rename', $renameValues);
|
||||
@ -3497,15 +3499,15 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
|
||||
$newDir .= $pick['name'];
|
||||
} elseif ($type == 'dir') {
|
||||
$renameValues = array(array(
|
||||
'from' => $oldfile,
|
||||
'to' => $newfile,
|
||||
'thumb' => $serendipity['thumbSuffix'],
|
||||
'fthumb' => $file['thumbnail_name'],
|
||||
'oldDir' => $oldDir,
|
||||
'newDir' => $newDir,
|
||||
'type' => $type,
|
||||
'item_id'=> $item_id,
|
||||
'file' => $file
|
||||
'from' => $oldfile,
|
||||
'to' => $newfile,
|
||||
'thumb' => $serendipity['thumbSuffix'],
|
||||
'fthumb' => $file['thumbnail_name'],
|
||||
'oldDir' => $oldDir,
|
||||
'newDir' => $newDir,
|
||||
'type' => $type,
|
||||
'item_id' => $item_id,
|
||||
'file' => $file
|
||||
));
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_media_rename', $renameValues);
|
||||
@ -3617,4 +3619,3 @@ function serendipity_checkDirUpload($dir) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user