I have a PHP script to re size image file as below;
$file = "test.bmp";
$ext = pathinfo($file, PATHINFO_EXTENSION);
$info = pathinfo($file);
$file_name = basename($file,'.'.$info['extension']);
$thumbname = "thumb/".$file_name.".".$ext;
$maxh = 200;
$maxw = 200;
$quality = 100;
list($width,$height)=getimagesize($file);
$src = imagecreatefromwbmp($file);
$tmp = imagecreatetruecolor($maxw,$maxh);
imagecopyresampled($tmp,$src,0,0,0,0,200,200,$width,$height);
imagejpeg($tmp,$thumbname,$quality);
imagedestroy($tmp);
The script is suppose to resize a Windows bitmap image to 200×200 thumbnail. But instead, I am getting a black 200×200 image. I am using PHP with Apache in Windows PC. How can I fix this?
.bmpandwbmpare VERY, VERY different file types.Note the
content-typeheaders:Calling
imagecreatefromwbmp($file)where$fileis a.bmpwill fail every time.See this thread for info on how to load a
.bmpfile. It’s not pretty.