I am developing an api that accepets image file in base64 encoded form from the mobile app.
Now the apis task to create that image file and store in server.
below is the code.
<?php
$file="mygif_image.gif";
$handle = fopen($file, "r");
if(!filesize($file)){
echo "corrupted file.."; die;
}
$image_contents = fread($handle, filesize($file));
fclose($handle);
$encoded_data = base64_encode($image_contents);
/* assume that this $encoded_data I am getting in api as request */
/* this will be the server side code, where encoded data is accepted and
I required to store image in server*/
$image_binary_content = base64_decode($encoded_data);
$im = imagecreatefromstring($image_binary_content);
if ($im !== false) {
header('Content-Type: image/gif');
imagegif($im,"mygif_image2.gif");
imagedestroy($im);
}else{
echo "some thing went wrong..";
}
?>
The image is getting stored properly at required place, issue is effects are not comming.
imagejpeg(), imagepng() such functions work very nice in case of jpg,joeg,png files.
Don't know which is the place, where something is going wrong ??