2

I am getting this error in all the functions of Image GD library. enter image description here

$im = @imagecreatefromjpeg("src/bg.jpg") or die('Cannot Initialize new GD image stream');
function copyImage1($im, $dp1_name, $x1, $y1){
    $dp1 = imagecreatefromjpeg($dp1_name);
    list($w1, $h1) = getimagesize($dp1_name);
    imagecopy($im, $dp1, 35, 130, 0, 0, $w1, $h1);
}
function copyImage2($im, $dp2_name, $x2, $y2){
    $dp2 = imagecreatefromjpeg($dp2_name);
    list($w2, $h2) = getimagesize($dp2_name);
    imagecopy($im, $dp2, 618, 125, 0, 0, $w2, $h2);
}

$box = imagettfbbox(30, 0, "src/font.ttf", $user_name);
imagettftext($im, 23, 0, 53, 348, imagecolorallocate($im, 73, 184, 227), "src/font.ttf", "hello");
imagettftext($im, 23, 0, 628, 348, imagecolorallocate($im, 73, 184, 227), "src/font.ttf", "byr");
copyImage1($im, "http://graph.facebook.com/100001504336690/picture?width=153&height=143", 10, 10);
copyImage2($im, "http://graph.facebook.com/100001504336690/picture?width=138&height=158", 10, 10);

$file_name = "dump/" . rand(1000, 9999) . "-id-" . rand(1000, 9999) . ".jpg"; 
imagejpeg($im, $file_name, 80);
imagedestroy($im);


?>

The files are available at their place,

Code was working fine but now it is not working. I don't know wyy it is not working now..

8
  • Can you copy and paste the error message here? If we have to chase down a network address it's really hard from a screenshot :p
    – Ben
    Commented Sep 19, 2013 at 2:52
  • 1
    Did you look at the Related questions. I'll bet anything one of them is the same problem as yours.
    – Barmar
    Commented Sep 19, 2013 at 2:53
  • Which line is the error happening on? And is that really the entire error message? The other questions have more details after failed:.
    – Barmar
    Commented Sep 19, 2013 at 2:53
  • If it was working before, what has changed? Your code? Your environment? Facebook's security policy?
    – user1864610
    Commented Sep 19, 2013 at 2:53
  • It looks like your internet connection is down or something.
    – Ben
    Commented Sep 19, 2013 at 2:53

3 Answers 3

1

The server that is running this code has DNS servers which it uses to resolve domain names, in this case, graph.facebook.com. It's either that those DNS servers are down or the server is misconfigured and can't reach whatever DNS servers it's supposed to use.

1
  • It is not even able to open file on the same server (src/bg.jpg) Commented Sep 19, 2013 at 3:01
1

Restarting apache server also resolved my issue. I recently moved to a dedicated server so there were some initial DNS issues.

0

The problem is solved, it just needed a apache restart.

Not the answer you're looking for? Browse other questions tagged or ask your own question.