Added thumb_scaling option for generating high-dpi thumbnails
This commit is contained in:
parent
8612a07a5a
commit
49cb6f7233
@ -57,6 +57,7 @@ class ET extends Extension
|
|||||||
$info['thumb_quality'] = $config->get_int('thumb_quality');
|
$info['thumb_quality'] = $config->get_int('thumb_quality');
|
||||||
$info['thumb_width'] = $config->get_int('thumb_width');
|
$info['thumb_width'] = $config->get_int('thumb_width');
|
||||||
$info['thumb_height'] = $config->get_int('thumb_height');
|
$info['thumb_height'] = $config->get_int('thumb_height');
|
||||||
|
$info['thumb_scaling'] = $config->get_int('thumb_scaling');
|
||||||
$info['thumb_mem'] = $config->get_int("thumb_mem_limit");
|
$info['thumb_mem'] = $config->get_int("thumb_mem_limit");
|
||||||
|
|
||||||
$info['stat_images'] = $database->get_one("SELECT COUNT(*) FROM images");
|
$info['stat_images'] = $database->get_one("SELECT COUNT(*) FROM images");
|
||||||
|
@ -41,6 +41,7 @@ Memory: {$info['thumb_mem']}
|
|||||||
Quality: {$info['thumb_quality']}
|
Quality: {$info['thumb_quality']}
|
||||||
Width: {$info['thumb_width']}
|
Width: {$info['thumb_width']}
|
||||||
Height: {$info['thumb_height']}
|
Height: {$info['thumb_height']}
|
||||||
|
Scaling: {$info['thumb_scaling']}
|
||||||
|
|
||||||
Shimmie stats:
|
Shimmie stats:
|
||||||
Images: {$info['stat_images']}
|
Images: {$info['stat_images']}
|
||||||
|
@ -88,8 +88,10 @@ class IcoFileHandler extends Extension
|
|||||||
$inname = warehouse_path("images", $hash);
|
$inname = warehouse_path("images", $hash);
|
||||||
$outname = warehouse_path("thumbs", $hash);
|
$outname = warehouse_path("thumbs", $hash);
|
||||||
|
|
||||||
$w = $config->get_int("thumb_width");
|
$tsize = get_thumbnail_size_scaled($width, $height);
|
||||||
$h = $config->get_int("thumb_height");
|
$w = $tsize[0];
|
||||||
|
$h = $tsise[1];
|
||||||
|
|
||||||
$q = $config->get_int("thumb_quality");
|
$q = $config->get_int("thumb_quality");
|
||||||
$mem = $config->get_int("thumb_mem_limit") / 1024 / 1024; // IM takes memory in MB
|
$mem = $config->get_int("thumb_mem_limit") / 1024 / 1024; // IM takes memory in MB
|
||||||
|
|
||||||
|
@ -103,8 +103,6 @@ class PixelFileHandler extends DataHandlerExtension
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$w = $config->get_int("thumb_width");
|
|
||||||
$h = $config->get_int("thumb_height");
|
|
||||||
$q = $config->get_int("thumb_quality");
|
$q = $config->get_int("thumb_quality");
|
||||||
$convert = $config->get_string("thumb_convert_path");
|
$convert = $config->get_string("thumb_convert_path");
|
||||||
|
|
||||||
@ -114,12 +112,10 @@ class PixelFileHandler extends DataHandlerExtension
|
|||||||
//$size = shell_exec($cmd);
|
//$size = shell_exec($cmd);
|
||||||
//$size = explode(" ", trim($size));
|
//$size = explode(" ", trim($size));
|
||||||
$size = getimagesize($inname);
|
$size = getimagesize($inname);
|
||||||
if ($size[0] > $size[1]*5) {
|
$tsize = get_thumbnail_size_scaled($size[0] , $size[1]);
|
||||||
$size[0] = $size[1]*5;
|
$w = $tsize[0];
|
||||||
}
|
$h = $tsize[1];
|
||||||
if ($size[1] > $size[0]*5) {
|
|
||||||
$size[1] = $size[0]*5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// running the call with cmd.exe requires quoting for our paths
|
// running the call with cmd.exe requires quoting for our paths
|
||||||
$format = '"%s" "%s[0]" -extent %ux%u -flatten -strip -thumbnail %ux%u -quality %u jpg:"%s"';
|
$format = '"%s" "%s[0]" -extent %ux%u -flatten -strip -thumbnail %ux%u -quality %u jpg:"%s"';
|
||||||
@ -158,8 +154,9 @@ class PixelFileHandler extends DataHandlerExtension
|
|||||||
$memory_limit = get_memory_limit();
|
$memory_limit = get_memory_limit();
|
||||||
|
|
||||||
if ($memory_use > $memory_limit) {
|
if ($memory_use > $memory_limit) {
|
||||||
$w = $config->get_int('thumb_width');
|
$tsize = get_thumbnail_size_scaled($width, $height);
|
||||||
$h = $config->get_int('thumb_height');
|
$w = $tsize[0];
|
||||||
|
$h = $tsize[1];
|
||||||
$thumb = imagecreatetruecolor($w, min($h, 64));
|
$thumb = imagecreatetruecolor($w, min($h, 64));
|
||||||
$white = imagecolorallocate($thumb, 255, 255, 255);
|
$white = imagecolorallocate($thumb, 255, 255, 255);
|
||||||
$black = imagecolorallocate($thumb, 0, 0, 0);
|
$black = imagecolorallocate($thumb, 0, 0, 0);
|
||||||
@ -167,15 +164,8 @@ class PixelFileHandler extends DataHandlerExtension
|
|||||||
imagestring($thumb, 5, 10, 24, "Image Too Large :(", $black);
|
imagestring($thumb, 5, 10, 24, "Image Too Large :(", $black);
|
||||||
return $thumb;
|
return $thumb;
|
||||||
} else {
|
} else {
|
||||||
if ($width > $height*5) {
|
|
||||||
$width = $height*5;
|
|
||||||
}
|
|
||||||
if ($height > $width*5) {
|
|
||||||
$height = $width*5;
|
|
||||||
}
|
|
||||||
|
|
||||||
$image = imagecreatefromstring(file_get_contents($tmpname));
|
$image = imagecreatefromstring(file_get_contents($tmpname));
|
||||||
$tsize = get_thumbnail_size($width, $height);
|
$tsize = get_thumbnail_size_scaled($width, $height);
|
||||||
|
|
||||||
$thumb = imagecreatetruecolor($tsize[0], $tsize[1]);
|
$thumb = imagecreatetruecolor($tsize[0], $tsize[1]);
|
||||||
imagecopyresampled(
|
imagecopyresampled(
|
||||||
|
@ -64,7 +64,7 @@ class VideoFileHandler extends DataHandlerExtension
|
|||||||
$outname = warehouse_path("thumbs", $hash);
|
$outname = warehouse_path("thumbs", $hash);
|
||||||
|
|
||||||
$orig_size = $this->video_size($inname);
|
$orig_size = $this->video_size($inname);
|
||||||
$scaled_size = get_thumbnail_size($orig_size[0], $orig_size[1]);
|
$scaled_size = get_thumbnail_size_scaled($orig_size[0], $orig_size[1]);
|
||||||
$cmd = escapeshellcmd(implode(" ", [
|
$cmd = escapeshellcmd(implode(" ", [
|
||||||
escapeshellarg($ffmpeg),
|
escapeshellarg($ffmpeg),
|
||||||
"-y", "-i", escapeshellarg($inname),
|
"-y", "-i", escapeshellarg($inname),
|
||||||
|
@ -19,6 +19,7 @@ class ImageIO extends Extension
|
|||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int('thumb_width', 192);
|
$config->set_default_int('thumb_width', 192);
|
||||||
$config->set_default_int('thumb_height', 192);
|
$config->set_default_int('thumb_height', 192);
|
||||||
|
$config->set_default_int('thumb_scaling', 100);
|
||||||
$config->set_default_int('thumb_quality', 75);
|
$config->set_default_int('thumb_quality', 75);
|
||||||
$config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB'));
|
$config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB'));
|
||||||
$config->set_default_string('thumb_convert_path', 'convert');
|
$config->set_default_string('thumb_convert_path', 'convert');
|
||||||
@ -148,6 +149,10 @@ class ImageIO extends Extension
|
|||||||
$sb->add_int_option("thumb_quality");
|
$sb->add_int_option("thumb_quality");
|
||||||
$sb->add_label(" % quality ");
|
$sb->add_label(" % quality ");
|
||||||
|
|
||||||
|
$sb->add_label("<br>High-DPI scaling ");
|
||||||
|
$sb->add_int_option("thumb_scaling");
|
||||||
|
$sb->add_label("%");
|
||||||
|
|
||||||
if ($config->get_string("thumb_engine") == "convert") {
|
if ($config->get_string("thumb_engine") == "convert") {
|
||||||
$sb->add_label("<br>ImageMagick Binary: ");
|
$sb->add_label("<br>ImageMagick Binary: ");
|
||||||
$sb->add_text_option("thumb_convert_path");
|
$sb->add_text_option("thumb_convert_path");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user