使用php,您可以使用读取文件夹内的文件
$images= glob("*"); // * will address all files
// or
$images= glob("*.jpg"); // this will address only jpg images
然后遍历$ images
foreach ($images as $filename) {
//resize the image
if(resizeImage($imagePath,$destPath,$NewImageWidth,$NewImageHeight,$Quality)){
echo $filename.' resize Success!
';
}
}
function resizeImage($SrcImage,$DestImage, $MaxWidth,$MaxHeight,$Quality)
{
list($iWidth,$iHeight,$type) = getimagesize($SrcImage);
//if you dont want to rescale image
$NewWidth=$MaxWidth;
$NewHeight=$MaxHeight;
$NewCanves = imagecreatetruecolor($NewWidth, $NewHeight);
// Resize Image
if(imagecopyresampled($NewCanves, $NewImage,0, 0, 0, 0, $NewWidth, $NewHeight, $iWidth, $iHeight))
{
// copy file
if(imagejpeg($NewCanves,$DestImage,$Quality))
{
imagedestroy($NewCanves);
return true;
}
}
}