I am creating a website that searches for photos. I found that functions in GD library are capable of resizing images through pre-created functions. I have created a test script to read and resize an image. It theoretically opens and reads an image to a variable then uses the read image to resize the image and display it before closing the file. The code I wrote is:
**before going on: I used header and specified the type but was told that this information was passed. When I checked the type it did return image/jpeg which is why this truly stumps me. What is returned by fopen and fread seems to be symbolic still.
However, I continue to get
Apparently, it is reading the file in symbols still. I specified binary in the fopen function with "rb".
Is there a way to make this work? I am using a Windows Parallels Plesk Server and the symbols don't look like binary.
***I tried without opening the file and just linking to it and the entire image was just symbols. The PHP manual recommends using fopen but the symbols keep appearing. I have used fread and readfile to try and open the image. All help is appreciated.
**before going on: I used header and specified the type but was told that this information was passed. When I checked the type it did return image/jpeg which is why this truly stumps me. What is returned by fopen and fread seems to be symbolic still.
Code:
<html> <body> <?php $percent=0.5; $filename="http://bytes.com/images/dtown.jpg"; $fp=fopen($filename,"rb"); $file=fread($fp,filesize($filename)); list($width,$height)=getimagesize($file); $new_width=$width*$percent; $new_height=$height*$percent; $image_p=imagecreatetruecolor($new_width,$new_height); $image=imagecreatefromjpeg($file); imagecopyresampled($image_p,$image,0,0,0,0,$new_width,$new_height,$width,$height); imagejpeg($image_p,null,100); fclose($fp); ?> </body> </html>
Code:
Warning: getimagesize(ÿØÿà) [function.getimagesize]: failed to open stream: No such file or directory in C:\Inetpub\vhosts\dumountaineer.com\httpdocs\dbimages\test.php on line 8 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Inetpub\vhosts\dumountaineer.com\httpdocs\dbimages\test.php on line 11 Warning: imagecreatefromjpeg(ÿØÿà) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in C:\Inetpub\vhosts\dumountaineer.com\httpdocs\dbimages\test.php on line 12 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\Inetpub\vhosts\dumountaineer.com\httpdocs\dbimages\test.php on line 13 Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\Inetpub\vhosts\dumountaineer.com\httpdocs\dbimages\test.php on line 14
Is there a way to make this work? I am using a Windows Parallels Plesk Server and the symbols don't look like binary.
***I tried without opening the file and just linking to it and the entire image was just symbols. The PHP manual recommends using fopen but the symbols keep appearing. I have used fread and readfile to try and open the image. All help is appreciated.
Comment