// Load the original image $original_image = imagecreatefromjpeg('path/to/original/image.jpg'); // Create thumbnail with specified width and height $thumbnail_image = imagecreatetruecolor(100, 100); imagecopyresampled($thumbnail_image, $original_image, 0, 0, 0, 0, 100, 100, imagesx($original_image), imagesy($original_image)); // Save the thumbnail image imagejpeg($thumbnail_image, 'path/to/thumbnail/image.jpg');
// Load the original image $original_image = imagecreatefrompng('path/to/original/image.png'); // Get original image dimensions $original_width = imagesx($original_image); $original_height = imagesy($original_image); // Calculate new dimensions for thumbnail $thumbnail_width = 100; $thumbnail_height = round(($original_height/$original_width) * $thumbnail_width); // Create thumbnail $thumbnail_image = imagecreatetruecolor($thumbnail_width, $thumbnail_height); imagecopyresampled($thumbnail_image, $original_image, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $original_width, $original_height); // Save the thumbnail image imagepng($thumbnail_image, 'path/to/thumbnail/image.png');This example loads an original PNG image and resizes it to create a thumbnail image with a width of 100 pixels and a proportional height. Based on the examples provided, it is likely that the package library being used is the GD library, which is a popular graphics library for image manipulation in PHP.