소스 검색

Option to automatically strip EXIF metadata from JPEGs

tags/vichan-devel-4.0.4-gold
Michael Foster 11 년 전
부모
커밋
308f557fd5
3개의 변경된 파일19개의 추가작업 그리고 7개의 파일을 삭제
  1. +3
    -0
      inc/config.php
  2. +10
    -2
      inc/image.php
  3. +6
    -5
      post.php

+ 3
- 0
inc/config.php 파일 보기

@@ -418,6 +418,9 @@
// - 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in PHP Imagick.
$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
// 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';


+ 10
- 2
inc/image.php 파일 보기

@@ -166,6 +166,9 @@ class ImageImagick extends ImageBase {
}
}
public function to($src) {
if ($config['strip_exif']) {
$this->image->stripImage();
}
if (preg_match('/\.gif$/i', $src))
$this->image->writeImages($src, true);
else
@@ -236,9 +239,14 @@ class ImageConvert extends ImageBase {
}
}
public function to($src) {
global $config;
if (!$this->temp) {
// $config['redraw_image']
shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src));
if ($config['strip_exif']) {
shell_exec('convert ' . escapeshellarg($this->src) . ' -strip ' . escapeshellarg($src));
} else {
shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src));
}
} else {
rename($this->temp, $src);
chmod($src, 0664);


+ 6
- 5
post.php 파일 보기

@@ -420,10 +420,11 @@ if (isset($_POST['delete'])) {
error($config['error']['maxsize']);
}
// The following code corrects the image orientation based on EXIF.
// 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 ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg') {
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.
if ($config['thumb_method'] == 'convert') {
$exif = exif_read_data($upload);
if (isset($exif['Orientation']) && $exif['Orientation'] != 1) {
shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload));
@@ -473,7 +474,7 @@ if (isset($_POST['delete'])) {
$thumb->_destroy();
}
if ($config['redraw_image']) {
if ($config['redraw_image'] || ($config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg'))) {
$image->to($post['file']);
$dont_copy_file = true;
}


불러오는 중...
취소
저장