I just loaded an image into memory via
$img = imagecreatefromjpeg($filename);
Then, I applied a rotation to the image:
$r_img = imagerotate($img, $angle, 0);
Per the docs, imagerotate() may change the dimensions of the image.  An example is rotating a rectangular image by anything other than 180 degrees.  The canvas will be expanded to accommodate the entire image, filling the empty areas with color "0" or black.
How can I get the new dimensions after rotation without writing the image out to a file? (getimagesize() requires a filename and doesn't appear to support a resource reference)
You can use imagesx() and imagesy()
imagesx-Returns the width of the given image resource.
imagesy-Returns the height of the given image resource.
$width  = imagesx($r_img);
$height = imagesy($r_img);
echo $width;
echo $height;
                        As far as I can see imagesx & imagesy should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With