我最近遇到了同样的问题,但我只是通过图像一次将它们从原来的2592×1944调整为300xbestFit或bestFitx300
我使用的是PHP类imagick而不是命令行,但是在我的情况下,通过更改为-scale或scaleImage,我将时间缩短了一半.这是我的测试代码的片段.
while ($images = readdir($handle)) {
// check to see if the first or second character is a '.' or '..',
// if so then remove from list
if (substr($images,0,1) != '.') {
//Check files to see if there extensions match any of the following image extensions.
// GLOB_BRACE looks for all glob criteria within the {braces}
$images = glob($dir."{*.gif,*.jpg,*.png,*.jpeg}", GLOB_BRACE);
// the glob function gives us an array of images
$i = 0;
foreach ($images as $image) {
// parse the data given and remove the images/ $dir,
// imagemagick will not take paths, only image names.
$i++;
list ($dir, $image) = s