get_image_size -- retrieve the height and width of an embedded image
array get_image_size ( int imageid )
This function can be used to retrieve the height and width (in
pixels) of an embedded image. Any type of image that can be embedded
via jfif_embed() or image_raw_embed() can be queried. imageid
must be the ID of the embedded image.
The value returned is an array in which the width
and
height
elements contain the respective pixel dimension.
Assuming that image.jpg
is a valid JFIF file, the
following code will extract the file data, embed it into the PDF
file, and echo the height and width.
$page = $pdf->new_page("letter"); $fh = fopen("image.jpg", "r"); $filedata = fread($fh, filesize("image.jpg")); fclose($fh); $image = $pdf->jfif_embed($filedata); $size = $pdf->get_image_size($image); echo "Height " . $size['height']; echo "Width " . $size['width'];
This function was added in version 1.14.