$PostImage = $_POST['PostImage'];
$imageBlob = base64_decode(str_ireplace('data:image/png;base64,','',$PostImage));
$im = new Imagick();
$im->readImageBlob($imageBlob);
//$im = new Imagick($_FILES['imageForPost']["tmp_name"]);
$imageprops = $im->getImageGeometry();
$finalWidth = 512;
$finalHeight = 512;
$ext = '.png';
$size = 100;
$name = time().$ext;//$_FILES["image"]["name"];
$width = $imageprops['width'];
$height = $imageprops['height'];
if($height > $finalHeight){
$newHeight = $finalHeight;
$newWidth = ($finalHeight / $height) * $width;
}else{
$newWidth = $imageprops['width'];
$newHeight = $imageprops['height'];
}
$im->scaleImage($finalWidth,$finalHeight,true,true);
$im->setOption('png:extent', $size.'kb');
$im->setImageFormat( "png" );
header("Content-Type: image/png");
echo $im;
Discover more from Soa Technology | Aditya Website Development Designing Company
Subscribe to get the latest posts sent to your email.