mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-23 23:20:57 +01:00
Remove 'convert_manual_orient' functionality.
It was supposed to help in case the user had an unspecified imagemagik version that was old in 2013...
This commit is contained in:
parent
e52c996a56
commit
24ebabb976
@ -788,8 +788,7 @@
|
||||
// Strip EXIF metadata from JPEG files.
|
||||
$config['strip_exif'] = false;
|
||||
// Use the command-line `exiftool` tool to strip EXIF metadata without decompressing/recompressing JPEGs.
|
||||
// Ignored when $config['redraw_image'] is true. This is also used to adjust the Orientation tag when
|
||||
// $config['strip_exif'] is false and $config['convert_manual_orient'] is true.
|
||||
// Ignored when $config['redraw_image'] is true.
|
||||
$config['use_exiftool'] = false;
|
||||
|
||||
// Redraw the image to strip any excess data (commonly ZIP archives) WARNING: This might strip the
|
||||
@ -803,11 +802,6 @@
|
||||
// this value doesn't matter as $config['redraw_image'] attempts to correct orientation too.)
|
||||
$config['convert_auto_orient'] = false;
|
||||
|
||||
// Is your version of ImageMagick or GraphicsMagick old? Older versions may not include the -auto-orient
|
||||
// switch. This is a manual replacement for that switch. This is independent from the above switch;
|
||||
// -auto-orrient is applied when thumbnailing too.
|
||||
$config['convert_manual_orient'] = false;
|
||||
|
||||
// Regular expression to check for an XSS exploit with IE 6 and 7. To disable, set to false.
|
||||
// Details: https://github.com/savetheinternet/Tinyboard/issues/20
|
||||
$config['ie_mime_type_detection'] = '/<(?:body|head|html|img|plaintext|pre|script|table|title|a href|channel|scriptlet)/i';
|
||||
|
@ -324,12 +324,7 @@ class ImageConvert extends ImageBase {
|
||||
error(_('Failed to resize image!'), null, $error);
|
||||
}
|
||||
} else {
|
||||
if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg'))
|
||||
$convert_args = str_replace('-auto-orient', ImageConvert::jpeg_exif_orientation($this->src), $config['convert_args']);
|
||||
elseif ($config['convert_manual_orient'])
|
||||
$convert_args = str_replace('-auto-orient', '', $config['convert_args']);
|
||||
else
|
||||
$convert_args = &$config['convert_args'];
|
||||
$convert_args = &$config['convert_args'];
|
||||
|
||||
if (($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
||||
sprintf($convert_args,
|
||||
@ -348,12 +343,8 @@ class ImageConvert extends ImageBase {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg'))
|
||||
$convert_args = str_replace('-auto-orient', ImageConvert::jpeg_exif_orientation($this->src), $config['convert_args']);
|
||||
elseif ($config['convert_manual_orient'])
|
||||
$convert_args = str_replace('-auto-orient', '', $config['convert_args']);
|
||||
else
|
||||
$convert_args = &$config['convert_args'];
|
||||
$convert_args = &$config['convert_args'];
|
||||
|
||||
if (($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
||||
sprintf($convert_args,
|
||||
$this->width,
|
||||
@ -380,69 +371,6 @@ class ImageConvert extends ImageBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For when -auto-orient doesn't exist (older versions)
|
||||
static public function jpeg_exif_orientation($src, $exif = false) {
|
||||
if (!$exif) {
|
||||
$exif = @exif_read_data($src);
|
||||
if (!isset($exif['Orientation']))
|
||||
return false;
|
||||
}
|
||||
switch($exif['Orientation']) {
|
||||
case 1:
|
||||
// Normal
|
||||
return false;
|
||||
case 2:
|
||||
// 888888
|
||||
// 88
|
||||
// 8888
|
||||
// 88
|
||||
// 88
|
||||
|
||||
return '-flop';
|
||||
case 3:
|
||||
|
||||
// 88
|
||||
// 88
|
||||
// 8888
|
||||
// 88
|
||||
// 888888
|
||||
|
||||
return '-flip -flop';
|
||||
case 4:
|
||||
// 88
|
||||
// 88
|
||||
// 8888
|
||||
// 88
|
||||
// 888888
|
||||
|
||||
return '-flip';
|
||||
case 5:
|
||||
// 8888888888
|
||||
// 88 88
|
||||
// 88
|
||||
|
||||
return '-rotate 90 -flop';
|
||||
case 6:
|
||||
// 88
|
||||
// 88 88
|
||||
// 8888888888
|
||||
|
||||
return '-rotate 90';
|
||||
case 7:
|
||||
// 88
|
||||
// 88 88
|
||||
// 8888888888
|
||||
|
||||
return '-rotate "-90" -flop';
|
||||
case 8:
|
||||
// 8888888888
|
||||
// 88 88
|
||||
// 88
|
||||
|
||||
return '-rotate "-90"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ImagePNG extends ImageBase {
|
||||
|
24
post.php
24
post.php
@ -999,27 +999,9 @@ if (isset($_POST['delete'])) {
|
||||
$exif = @exif_read_data($file['tmp_name']);
|
||||
$gm = in_array($config['thumb_method'], array('gm', 'gm+gifsicle'));
|
||||
if (isset($exif['Orientation']) && $exif['Orientation'] != 1) {
|
||||
if ($config['convert_manual_orient']) {
|
||||
$error = shell_exec_error(($gm ? 'gm ' : '') . 'convert ' .
|
||||
escapeshellarg($file['tmp_name']) . ' ' .
|
||||
ImageConvert::jpeg_exif_orientation(false, $exif) . ' ' .
|
||||
($config['strip_exif'] ? '+profile "*"' :
|
||||
($config['use_exiftool'] ? '' : '+profile "*"')
|
||||
) . ' ' .
|
||||
escapeshellarg($file['tmp_name']));
|
||||
if ($config['use_exiftool'] && !$config['strip_exif']) {
|
||||
if ($exiftool_error = shell_exec_error(
|
||||
'exiftool -overwrite_original -q -q -orientation=1 -n ' .
|
||||
escapeshellarg($file['tmp_name'])))
|
||||
error(_('exiftool failed!'), null, $exiftool_error);
|
||||
} else {
|
||||
// TODO: Find another way to remove the Orientation tag from the EXIF profile
|
||||
// without needing `exiftool`.
|
||||
}
|
||||
} else {
|
||||
$error = shell_exec_error(($gm ? 'gm ' : '') . 'convert ' .
|
||||
escapeshellarg($file['tmp_name']) . ' -auto-orient ' . escapeshellarg($upload));
|
||||
}
|
||||
$error = shell_exec_error(($gm ? 'gm ' : '') . 'convert ' .
|
||||
escapeshellarg($file['tmp_name']) . ' -auto-orient ' . escapeshellarg($upload));
|
||||
|
||||
if ($error)
|
||||
error(_('Could not auto-orient image!'), null, $error);
|
||||
$size = @getimagesize($file['tmp_name']);
|
||||
|
Loading…
Reference in New Issue
Block a user