0

This is the code I have:

$from = ...; // original uploaded file
$target = ...; // save path for optimized file
@unlink($target); // removes file if already exists
$image_o = imagecreatefromjpeg($from); // get a file
imagejpeg($image_o, $target, 85); // save optimized
imagedestroy($image_o); // free memory

But it doesn't do anything. This is going in loop, but now I test it on the single file. Seems to be working on smaller files. I tried image with size ~120 kB and optimized OK. But file with more than 1 MB, it will do nothing and those are files I really need to optimize. I also tried this:

set_time_limit(6000);
ini_set('memory_limit', '200M');

But no help. I'm working on a shared hosting, so I have no access to the php.ini or to install 3rd party PHP extension. Is there an alternative for imagecreatefromjpeg which seems to be the problem?

Patrik Krehák
  • 2,595
  • 8
  • 32
  • 62

0 Answers0