0

my image has about 5000x3000 pixels and I want to use the imagecreatefromjpeg function in PHP, however the image keeps just empty. When I try it with a smaller one It is working perfectly. I tried to set the memory_limit to 800M and also ini_set('memory_limit', -1);.

My code:

header("Content-type: image/png");
ini_set('memory_limit', -1);
error_reporting(E_ALL);

$img1 = imagecreatefromjpeg("1.jpg");
$img2 = imagecreatefromjpeg('2.jpg');

imagecopy($img1, $img2, 605, 109, 0, 0, 200, 200);

imagepng($img1);
imagedestroy($img1);

Output: Output

Errors: Errors

What else can I do

Phil
  • 157,677
  • 23
  • 242
  • 245
  • What do you mean by *"empty"*? Is it returning boolean `false`? Do you have error reporting set to `E_ALL` and `display_errors` enabled? – Phil Aug 03 '17 at 01:45
  • Have you also adjusted server file upload size, and post size? http://php.net/manual/en/function.imagecreatefromjpeg.php#96227 Any error in php logs file? – Chris Chen Aug 03 '17 at 01:46
  • @ChrisChen only really applicable if OP is uploading the image but that could definitely be the case :) – Phil Aug 03 '17 at 01:51
  • I just tried increasing the post and file upload size, however it didn't help. (Edited my post). –  Aug 03 '17 at 01:55
  • Add `ini_set('display_errors', 'On')` – Phil Aug 03 '17 at 01:59
  • Edited the post. –  Aug 03 '17 at 02:05
  • 1
    ini_set ('gd.jpeg_ignore_warning', 1); according to the refered question – Chris Chen Aug 03 '17 at 05:29

0 Answers0