Note that there are some explanatory texts on larger screens.

plurals
  1. POUse curl to open GD image
    text
    copied!<p>I want to add some watermarks on a image, but this image is on the other server, which created by GD lib, that means I'm opening a url like (http://www.abc.com/image.php), however, the remote server was disable the allow_url_open, and I have no way to enable this. So here is my code using curl</p> <pre><code>function loadimg($url) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_HEADER, false); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0); $rawdata = curl_exec($ch); $image = imagecreatefromstring($rawdata); curl_close($ch); return imagejpeg($image); } </code></pre> <p>And I test with the code and get this</p> <p>Warning: imagecreatefromstring() [function.imagecreatefromstring]: Data is not in a recognized format in D:\AppServ\www\index2.php on line 25</p> <p>after that, I check the content I get, it got a html file, as follow, it seems it redirect to somewhere, instead of get an image, however, when I open the link in the browser, it did show the image correctly.</p> <pre><code>&lt;head&gt; &lt;meta http-equiv="refresh" content="0;url=http://ifastnet.com/notify2.html" /&gt; &lt;/head&gt; &lt;html&gt; &lt;body&gt; &lt;script LANGUAGE="JavaScript"&gt; window.location="http://ifastnet.com/notify2.html"; &lt;/script&gt; &lt;!-- 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 526 640 917 51 415 140 573 716 965 688 395 829 76 810 801 733 244 95 205 283 488 189 705 173 743 574 947 608 694 973 886 298 223 449 99 309 936 432 209 623 454 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 526 640 917 51 415 140 573 716 965 688 395 829 76 810 801 733 244 95 205 283 488 189 705 173 743 574 947 608 694 973 886 298 223 449 99 309 936 432 209 623 454 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 526 640 917 51 415 140 573 716 965 688 395 829 76 810 801 733 244 95 205 283 488 189 705 173 743 574 947 608 694 973 886 298 223 449 99 309 936 432 209 623 454 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 526 640 917 51 415 140 573 716 965 688 395 829 76 810 801 733 244 95 205 283 488 189 705 173 743 574 947 608 694 973 886 298 223 449 99 309 936 432 209 623 454 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 399 310 772 188 121 747 908 375 658 989 471 891 842 282 539 788 863 526 640 917 51 415 140 573 716 965 688 395 829 76 810 801 733 244 95 205 283 488 189 705 173 743 574 947 608 694 973 886 298 223 449 99 309 936 432 209 623 454 --&gt; &lt;/body&gt; &lt;/html&gt; &lt;BR clear="all"&gt; &lt;HR noshade size="1px"&gt; &lt;ADDRESS&gt; Generated Mon, 07 Feb 2011 18:03:15 GMT by demil1.byetcluster.com (Lusca/LUSCA_HEAD-r14756) &lt;/ADDRESS&gt; &lt;/BODY&gt;&lt;/HTML&gt; </code></pre> <p>Please help~ thanks a lot~!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload