Option to automatically strip EXIF metadata from JPEGs
This commit is contained in:
parent
e8b693b044
commit
308f557fd5
|
@ -418,6 +418,9 @@
|
||||||
// - 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in PHP Imagick.
|
// - 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in PHP Imagick.
|
||||||
$config['thumb_method'] = 'gd';
|
$config['thumb_method'] = 'gd';
|
||||||
|
|
||||||
|
// Strip EXIF metadata from JPEG files
|
||||||
|
$config['strip_exif'] = false;
|
||||||
|
|
||||||
// Regular expression to check for IE MIME type detection XSS exploit. To disable, comment the line out
|
// Regular expression to check for IE MIME type detection XSS exploit. To disable, comment the line out
|
||||||
// https://github.com/savetheinternet/Tinyboard/issues/20
|
// 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';
|
$config['ie_mime_type_detection'] = '/<(?:body|head|html|img|plaintext|pre|script|table|title|a href|channel|scriptlet)/i';
|
||||||
|
|
|
@ -166,6 +166,9 @@ class ImageImagick extends ImageBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function to($src) {
|
public function to($src) {
|
||||||
|
if ($config['strip_exif']) {
|
||||||
|
$this->image->stripImage();
|
||||||
|
}
|
||||||
if (preg_match('/\.gif$/i', $src))
|
if (preg_match('/\.gif$/i', $src))
|
||||||
$this->image->writeImages($src, true);
|
$this->image->writeImages($src, true);
|
||||||
else
|
else
|
||||||
|
@ -236,9 +239,14 @@ class ImageConvert extends ImageBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function to($src) {
|
public function to($src) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (!$this->temp) {
|
if (!$this->temp) {
|
||||||
// $config['redraw_image']
|
if ($config['strip_exif']) {
|
||||||
|
shell_exec('convert ' . escapeshellarg($this->src) . ' -strip ' . escapeshellarg($src));
|
||||||
|
} else {
|
||||||
shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src));
|
shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rename($this->temp, $src);
|
rename($this->temp, $src);
|
||||||
chmod($src, 0664);
|
chmod($src, 0664);
|
||||||
|
|
7
post.php
7
post.php
|
@ -420,10 +420,11 @@ if (isset($_POST['delete'])) {
|
||||||
error($config['error']['maxsize']);
|
error($config['error']['maxsize']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following code corrects the image orientation based on EXIF.
|
|
||||||
|
if ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg') {
|
||||||
|
// The following code corrects the image orientation.
|
||||||
// Currently only works with the 'convert' option selected but it could easily be expanded to work with the rest if you can be bothered.
|
// Currently only works with the 'convert' option selected but it could easily be expanded to work with the rest if you can be bothered.
|
||||||
if ($config['thumb_method'] == 'convert') {
|
if ($config['thumb_method'] == 'convert') {
|
||||||
if ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg') {
|
|
||||||
$exif = exif_read_data($upload);
|
$exif = exif_read_data($upload);
|
||||||
if (isset($exif['Orientation']) && $exif['Orientation'] != 1) {
|
if (isset($exif['Orientation']) && $exif['Orientation'] != 1) {
|
||||||
shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload));
|
shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload));
|
||||||
|
@ -473,7 +474,7 @@ if (isset($_POST['delete'])) {
|
||||||
$thumb->_destroy();
|
$thumb->_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['redraw_image']) {
|
if ($config['redraw_image'] || ($config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg'))) {
|
||||||
$image->to($post['file']);
|
$image->to($post['file']);
|
||||||
$dont_copy_file = true;
|
$dont_copy_file = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue