imagesy
imagesy($image)
Returns the height of a GD image in pixels. Together with imagesx() it is used to calculate the dimensions of a thumbnail or the position of a watermark.
Parameters
- $image – a GD image.
Examples
$photo = imagecreatefromjpeg("photo.jpg");
echo imagesy($photo); // 333
// the height of a thumbnail 300 points wide
echo (int) round(imagesy($photo) * 300 / imagesx($photo)); // 200
// a strip for a caption at the bottom edge
$y = imagesy($photo) - 30;
imagefilledrectangle($photo, 0, $y, imagesx($photo) - 1, imagesy($photo) - 1, imagecolorallocatealpha($photo, 0, 0, 0, 60));
echo $y; // 303
Things to watch out for
- Coordinates in GD start at zero – the last row of the image has y =
imagesy($image) - 1.
Related functions:
imagesx()
getimagesize()
imagescale()
imagefilledrectangle()