Code: Select all
<?php
$original = '/path/to/original.jpg';
$thumb = imagecreatetruecolor(100,100);
$size = getimagesize($original);
imagecopyresampled($thumb, $original, 0, 0, 0, 0, 100, 100, $size[0], $size[1]);
ob_start();
imagejpeg($thumb);
$content = ob_get_contents();
ob_end_clean();
file_put_contents('/path/to/thumbnail.jpg', $content);
?>Is there also a way to create a thumbnail before the original image is on disk? I.e. I have the file via $_FILES, but not on disk yet.