// Open image file $image = imagecreatefromjpeg('image.jpg'); // Get image height $height = imagesy($image); // Output image height echo "The height of the image is: " . $height;
// Open image file $image = imagecreatefrompng('image.png'); // Get image height $height = imagesy($image); if($height > 1000) { // Resize image $resized = imagescale($image, 800); imagepng($resized, 'resized.png'); } else { // Output original image header('Content-Type: image/png'); imagepng($image); }This example opens a PNG image file and checks if its height is greater than 1000 pixels. If it is, the image is resized using imagescale and the resized image is saved to a file. If the height is less than or equal to 1000 pixels, the original image is outputted to the browser. Package/Library: GD Library, which is bundled with PHP.