With php you can read the files inside a folder using
$images= glob("*"); // * will address all files
// or
$images= glob("*.jpg"); // this will address only jpg images
Then loop through $images
foreach ($images as $filename) {
//resize the image
if(resizeImage($imagePath,$destPath,$NewImageWidth,$NewImageHeight,$Quality)){
echo $filename.' resize Success!<br />';
}
}
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;
}
}
}