Ask for a user-defined function to determine the image format. after writing the image, it cannot be output normally. The image is in jpg format and can be output normally without a user-defined function, the code is as follows: function & nbsp; image_check ($ aa, $ im) {& nbsp; $ img = getimagesize ($ aa ); & nbsp ask for a user-defined function to determine the image format
The user-defined function used to determine the image format. after writing the image, it cannot be output normally. The image is in jpg format and can be output normally without a user-defined function. the code is as follows:
Function image_check ($ aa, $ im)
{
$ Img = getimagesize ($ aa );
Switch ($ img [2])
{
Case 1;
$ Im = @ imagecreatefromgif ($ aa );
Break;
Case 2;
$ Im = @ imagecreatefromjpeg ($ aa );
Break;
Case 3;
$ Im = @ imagecreatefrompng ($ aa );
Break;
}
Return $ im;
}
$ Image = 'C: \ www \ news \ Winter.jpg ';
Image_check ($ image, $ bb );
Header ("Content-type: image/jpeg ");
Imagejpeg ($ bb );
------ Solution --------------------
function image_check($aa)
{
$img=getimagesize($aa);
switch($img[2])
{
case 1;
$im=@imagecreatefromgif($aa);
break;
case 2;
$im=@imagecreatefromjpeg($aa);
break;
case 3;
$im=@imagecreatefrompng($aa);
break;
}
return $im;
}
$image='c:\www\news\Winter.jpg';
$bb=image_check($image);
header("Content-type:image/jpeg");
imagejpeg($bb);
I just read it. it should be the question of passing parameters. now I have changed it. can you try it?