on my website you can upload images and I intend to allow at least 16k resolution for each upload. When displaying the image on the website I want to use a thumbnail image.
To create the thumbnail image I'm using the php code below:
<?php
$imageUploadFile = $_FILES["passimagefile"]["tmp_name"];
$src = imagecreatefromjpeg($imageUploadFile);
list( $width, $height ) = getimagesize( $imageUploadFile );
$tmp = imagecreatetruecolor( $width / $height * 700, 700 );
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $width / $height * 700, 700, $width, $height);
imagejpeg($tmp, $taget_thumbnail, 75);
?>
This works perfectly fine for most smaller (1k-4k) images. The thumbnail is correctly being generated. However, when I go and try to do it with an image that is like 6k or 8k the result is suddenly wrong.
The thumbnail image is being generated however it is completely black.
Is there a way to fix this?
There is many quirks in php-gd, often requiring a lot of trials and errors!
You might had reach an internal limit, thus try to generate your image, but resize it down before exporting, examples:
If it doesn't works, you have to consider joining many images, as tiles.
For advanced stuffs, in Linux, you can try to use the shell (from php) and imagemagick instead. http://www.imagemagick.org/Usage/text/