Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
This commit is contained in:
commit
1f5ce14f59
@ -505,7 +505,7 @@
|
|||||||
|
|
||||||
// Command-line options passed to ImageMagick when using `convert` for thumbnailing. Don't touch the
|
// Command-line options passed to ImageMagick when using `convert` for thumbnailing. Don't touch the
|
||||||
// placement of "%s" and "%d".
|
// placement of "%s" and "%d".
|
||||||
$config['convert_args'] = '-size %dx%d %s -thumbnail %dx%d +profile "*" %s';
|
$config['convert_args'] = '-size %dx%d %s -thumbnail %dx%d -auto-orient +profile "*" %s';
|
||||||
|
|
||||||
// Strip EXIF metadata from JPEG files.
|
// Strip EXIF metadata from JPEG files.
|
||||||
$config['strip_exif'] = false;
|
$config['strip_exif'] = false;
|
||||||
|
@ -248,15 +248,25 @@ class ImageConvert extends ImageBase {
|
|||||||
|
|
||||||
$this->temp = false;
|
$this->temp = false;
|
||||||
}
|
}
|
||||||
|
public function get_size($src, $try_gd_first = true) {
|
||||||
|
if ($try_gd_first) {
|
||||||
|
if ($size = @getimagesize($src))
|
||||||
|
return $size;
|
||||||
|
}
|
||||||
|
$size = shell_exec_error(($this->gm ? 'gm ' : '') . 'identify -format "%w %h" ' . escapeshellarg($src . '[0]'));
|
||||||
|
if (preg_match('/^(\d+) (\d+)$/', $size, $m))
|
||||||
|
return array($m[1], $m[2]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public function from() {
|
public function from() {
|
||||||
if ($this->width > 0 && $this->height > 0) {
|
if ($this->width > 0 && $this->height > 0) {
|
||||||
$this->image = true;
|
$this->image = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$size = shell_exec_error(($this->gm ? 'gm ' : '') . 'identify -format "%w %h" ' . escapeshellarg($this->src . '[0]'));
|
$size = $this->get_size($this->src, false);
|
||||||
if (preg_match('/^(\d+) (\d+)$/', $size, $m)) {
|
if ($size) {
|
||||||
$this->width = $m[1];
|
$this->width = $size[1];
|
||||||
$this->height = $m[2];
|
$this->height = $size[2];
|
||||||
|
|
||||||
$this->image = true;
|
$this->image = true;
|
||||||
} else {
|
} else {
|
||||||
@ -272,13 +282,13 @@ class ImageConvert extends ImageBase {
|
|||||||
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
||||||
escapeshellarg($this->src) . ' -auto-orient -strip ' . escapeshellarg($src))) {
|
escapeshellarg($this->src) . ' -auto-orient -strip ' . escapeshellarg($src))) {
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
error('Failed to resize image!', null, $error);
|
error('Failed to redraw image!', null, $error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
||||||
escapeshellarg($this->src) . ' -auto-orient ' . escapeshellarg($src))) {
|
escapeshellarg($this->src) . ' -auto-orient ' . escapeshellarg($src))) {
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
error('Failed to resize image!', null, $error);
|
error('Failed to redraw image!', null, $error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -324,6 +334,10 @@ class ImageConvert extends ImageBase {
|
|||||||
$this->height,
|
$this->height,
|
||||||
escapeshellarg($this->temp))) || !file_exists($this->temp))
|
escapeshellarg($this->temp))) || !file_exists($this->temp))
|
||||||
error('Failed to resize image!', null, $error);
|
error('Failed to resize image!', null, $error);
|
||||||
|
if ($size = $this->get_size($this->temp)) {
|
||||||
|
$this->width = $size[0];
|
||||||
|
$this->height = $size[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
if ($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
||||||
@ -335,6 +349,10 @@ class ImageConvert extends ImageBase {
|
|||||||
$this->height,
|
$this->height,
|
||||||
escapeshellarg($this->temp))) || !file_exists($this->temp))
|
escapeshellarg($this->temp))) || !file_exists($this->temp))
|
||||||
error('Failed to resize image!', null, $error);
|
error('Failed to resize image!', null, $error);
|
||||||
|
if ($size = $this->get_size($this->temp)) {
|
||||||
|
$this->width = $size[0];
|
||||||
|
$this->height = $size[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
post.php
3
post.php
@ -452,7 +452,7 @@ if (isset($_POST['delete'])) {
|
|||||||
if ($config['convert_auto_orient'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')) {
|
if ($config['convert_auto_orient'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')) {
|
||||||
// The following code corrects the image orientation.
|
// 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['redraw_image'] || ($config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')))) {
|
if (!($config['redraw_image'] || (($config['strip_exif'] && !$config['strip_with_exiftool']) && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')))) {
|
||||||
if (in_array($config['thumb_method'], array('convert', 'convert+gifsicle', 'gm', 'gm+gifsicle'))) {
|
if (in_array($config['thumb_method'], array('convert', 'convert+gifsicle', 'gm', 'gm+gifsicle'))) {
|
||||||
$exif = exif_read_data($upload);
|
$exif = exif_read_data($upload);
|
||||||
$gm = in_array($config['thumb_method'], array('gm', 'gm+gifsicle'));
|
$gm = in_array($config['thumb_method'], array('gm', 'gm+gifsicle'));
|
||||||
@ -460,6 +460,7 @@ if (isset($_POST['delete'])) {
|
|||||||
if($error = shell_exec_error(($gm ? 'gm ' : '') . 'convert ' .
|
if($error = shell_exec_error(($gm ? 'gm ' : '') . 'convert ' .
|
||||||
escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)))
|
escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)))
|
||||||
error('Could not auto-orient image!', null, $error);
|
error('Could not auto-orient image!', null, $error);
|
||||||
|
$size = @getimagesize($upload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user