I am working on an upload script but I'm having some trouble with uploading huge images.
Our client needs to upload files of around 20000x20000 pixels, yes, thousands. To make it even worse, his clients need to be able to hit that as well.
Now the uploading itself is not the problem, but the image needs to be loaded in the browser, so we need a small version of it.
The following code works, but it uses way too much RAM
$imgString = file_get_contents($file['tmp_name']);
$image = imagecreatefromstring($imgString);
$tmp = imagecreatetruecolor($width, $height);
$color = imagecolorallocate($tmp, 255, 255, 255);
imagefill($tmp, 0, 0, $color);
imagecopyresampled($tmp, $image, 0, 0, 0, 0, $width, $height, $oldWidth, $oldHeight);
But it takes too much RAM-memory it crashes. Our VPS (currently) only has 4gb currently, with 3,5gb allocated to Apache for testing (of course not recommended for production).
What do you recommend for this resize process instead of doing it this way? My boss doesn't really like third-party options we can't host ourselves like Uploadcare.