Thumbnailing alternative: convert
(command line ImageMagick instead of PHP bindings)
This commit is contained in:
parent
d531487bad
commit
4c3486bec9
@ -102,7 +102,7 @@
|
|||||||
// Use a persistent connection (experimental)
|
// Use a persistent connection (experimental)
|
||||||
$config['db']['persistent'] = false;
|
$config['db']['persistent'] = false;
|
||||||
// Anything more to add to the DSN string (eg. port=xxx;foo=bar)
|
// Anything more to add to the DSN string (eg. port=xxx;foo=bar)
|
||||||
$config['db']['dsn'] = '';
|
$config['db']['dsn'] = 'charset=UTF-8';
|
||||||
// Timeout duration in seconds (not all drivers support this)
|
// Timeout duration in seconds (not all drivers support this)
|
||||||
$config['db']['timeout'] = 5;
|
$config['db']['timeout'] = 5;
|
||||||
|
|
||||||
@ -363,6 +363,9 @@
|
|||||||
// Use Imagick instead of GD (some further config options below are ignored if set)
|
// Use Imagick instead of GD (some further config options below are ignored if set)
|
||||||
$config['imagick'] = false;
|
$config['imagick'] = false;
|
||||||
|
|
||||||
|
// Use the command line version of ImagickMagick rather than the PHP bindings.
|
||||||
|
$config['imagick_convert'] = 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';
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
$this->format = $format;
|
$this->format = $format;
|
||||||
|
|
||||||
if($config['imagick']) {
|
if($config['imagick']) {
|
||||||
$classname = 'ImageImagick';
|
$classname = $config['imagick_convert'] ? 'ImageConvert' : 'ImageImagick';
|
||||||
} else {
|
} else {
|
||||||
$classname = 'Image' . strtoupper($this->format);
|
$classname = 'Image' . strtoupper($this->format);
|
||||||
if(!class_exists($classname)) {
|
if(!class_exists($classname)) {
|
||||||
@ -39,7 +39,7 @@
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if($config['imagick']) {
|
if($config['imagick']) {
|
||||||
$classname = 'ImageImagick';
|
$classname = $config['imagick_convert'] ? 'ImageConvert' : 'ImageImagick';
|
||||||
} else {
|
} else {
|
||||||
$classname = 'Image' . strtoupper($extension);
|
$classname = 'Image' . strtoupper($extension);
|
||||||
if(!class_exists($classname)) {
|
if(!class_exists($classname)) {
|
||||||
@ -200,13 +200,53 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->image = clone $this->original;
|
$this->image = clone $this->original;
|
||||||
// only resize one frame
|
|
||||||
$this->image->scaleImage($this->width, $this->height, false);
|
$this->image->scaleImage($this->width, $this->height, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ImageConvert extends ImageBase {
|
||||||
|
public $width, $height, $temp;
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$this->temp = tempnam($config['tmp'], 'imagick');
|
||||||
|
|
||||||
|
}
|
||||||
|
public function from() {
|
||||||
|
if(!$size = @getimagesize($this->src))
|
||||||
|
return $this->image = false;
|
||||||
|
|
||||||
|
$this->width = $size[0];
|
||||||
|
$this->height = $size[1];
|
||||||
|
|
||||||
|
// mark as valid
|
||||||
|
$this->image = true;
|
||||||
|
}
|
||||||
|
public function to($src) {
|
||||||
|
rename($this->temp, $src);
|
||||||
|
}
|
||||||
|
public function width() {
|
||||||
|
return $this->width;
|
||||||
|
}
|
||||||
|
public function height() {
|
||||||
|
return $this->height;
|
||||||
|
}
|
||||||
|
public function destroy() {
|
||||||
|
unlink($this->temp);
|
||||||
|
}
|
||||||
|
public function resize() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$quality = $config['thumb_quality'] * 10;
|
||||||
|
|
||||||
|
if(shell_exec("convert -flatten -filter Point -resize {$this->width}x{$this->height} -quality {$quality} " . escapeshellarg($this->src) . " " . escapeshellarg($this->temp)))
|
||||||
|
error('Failed to resize image!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ImagePNG extends ImageBase {
|
class ImagePNG extends ImageBase {
|
||||||
public function from() {
|
public function from() {
|
||||||
$this->image = @imagecreatefrompng($this->src);
|
$this->image = @imagecreatefrompng($this->src);
|
||||||
|
Loading…
Reference in New Issue
Block a user