Willstedt Posted August 28, 2007 Share Posted August 28, 2007 Hi I am totally stuck with my image rescaling script and need help. The script is supposed to download images from the net, rescale them and save a local copy. The image url to be rescaled is sent to the script in a query string. The problem is image links with special characters like å, æ ø, ä, ö and similar; I can't get them decoded correctly. This basic script displays the essense of the problem: image_scale.php?file=http://www.mpx.no/img/produktbilder/Olympus/Kamera%20tilbehør/E0413744.jpg <?php $file = $_REQUEST["file"]; $file = rawurldecode($file); $dst_img=ImageCreateTrueColor(80,80); $src_img=imagecreatefromjpeg($file); imagecopyresampled($dst_img,$src_img,0,0,0,0,80,80,80,80); Header("Content-type: image/jpeg"); Imagejpeg($dst_img,'',60); imagedestroy($dst_img); imagedestroy($src_img); ?> The strange thing is that the script works perfectly fine if I paste the url to the image directly into the code like this: <?php $file = "http://www.mpx.no/img/produktbilder/Olympus/Kamera%20tilbehør/E0413744.jpg"; $dst_img=ImageCreateTrueColor(80,80); $src_img=imagecreatefromjpeg($file); imagecopyresampled($dst_img,$src_img,0,0,0,0,80,80,80,80); Header("Content-type: image/jpeg"); Imagejpeg($dst_img,'',60); imagedestroy($dst_img); imagedestroy($src_img); ?> I have tried a ton of different UTF-8 encode/decode, Rawurl Encode/Decode and just have to admit to myself that I can't solve the problem. Please help me - this is getting quite frustrating :'( Cheers Anders Quote Link to comment https://forums.phpfreaks.com/topic/67083-query-string-decoding-im-totally-stuck/ Share on other sites More sharing options...
Willstedt Posted August 28, 2007 Author Share Posted August 28, 2007 I should probably mention the error message I get when trying to parse the posted query string: Warning: imagecreatefromjpeg(http://www.mpx.no/img/produktbilder/Olympus/Kamera tilbehør/E0413744.jpg) [function.imagecreatefromjpeg]: failed to open stream: HTTP request failed! HTTP/1.1 400 The imagecreatefromjpeg function works fine if I set the same image link as a variable in the script. Does anyone have a clue about the solution to the problem? Quote Link to comment https://forums.phpfreaks.com/topic/67083-query-string-decoding-im-totally-stuck/#findComment-336692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.