I am trying to replace image code and resize it at the same time
but gave me error.
Warning: getimagesize($1): failed to open stream: No such file or directory in C:\wamp\www\ . . . . .
public function resize_Images($originalImage,$toWidth,$toHeight){
// Get the original geometry and calculate scales
list($width, $height) = getimagesize($originalImage);
$xscale=$width/$toWidth;
$yscale=$height/$toHeight;
// Recalculate new size with default ratio
if ($yscale>$xscale){
$new_width = round($width * (1/$yscale));
$new_height = round($height * (1/$yscale));
}
else {
$new_width = round($width * (1/$xscale));
$new_height = round($height * (1/$xscale));
}
// Resize the original image
$imageResized = imagecreatetruecolor($new_width, $new_height);
$imageTmp = imagecreatefromjpeg ($originalImage);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
return $imageResized;
}
public function bhl_bbcodes($str) {
$simple_search = array(
'/\[img\](.*?)\[\/img\]/is',
);
$simple_replace = array(
'<img src="'.$this->resize_Images('$1', 700, 500).'" />',
);
$str = preg_replace ($simple_search, $simple_replace, $str);
return $str;
}