I am new to facebook app development and working over my first app.
I am trying to resize an image using imagecopyresampled() function but getting this error for it:
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in …
$url = "http://graph.facebook.com/{$userId}/picture?type=large";
$img = "udp.gif";
file_put_contents($img, file_get_contents($url));
if (exif_imagetype($img) != IMAGETYPE_GIF) {
$imgFile = 'temp/' . $userId . '_fdp_' . rand() . '.gif';
if (exif_imagetype($img) == IMAGETYPE_JPEG)
$imageObject = imagecreatefromjpeg($img);
if (exif_imagetype($img) == IMAGETYPE_PNG)
$imageObject = imagecreatefrompng($img);
$imagegif($imageObject, $imgFile);
$imgFile1='temp/' . $userId . '_fdp_.gif';
$imagecopyresampled($imgFile1, $imgFile, 0, 0, 0, 0, 200, 280, 180, 252);
$img = $imgFile1;
}
}
}
You’re misunderstanding the argument types.
resourceis a PHP type, likestringorfloat. Resources need to be created with the appropriate related function. In your case, you need oneresourceof the original image, created with a function likeimagecreatefromjpeg, and another similarresourceto copy the image to, most likely a blank image created withimagecreatetruecolor.To quote the example from the manual:
What you have instead is a non-existent variable and a string, which is not the required input.