We should take care when using an image's sizes using height and width attributes. The main one is the ratio of the width and height of an image.
If these attributes are not known, we must first get them through the getimagesize function of PHP .
list($width, $height, $type, $attr) = getimagesize("../images/Imagem005.jpg");
Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. The index 2 is an indication of the image type: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF (intel byte order), 8 = TIFF order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants that were added in PHP 4.3. Index 3 is a string with the correct height="yyy" width="xxx" that can be used directly in an IMG tag. getimagesize
As we are only interested in the height and width attributes we will use
list($width, $height) = getimagesize("../images/Imagem005.jpg");
//nova largura
$newWidth = 200;
//nova altura
$newHeight = ($newWidth*$height)/$width;
echo "<img src=\"../images/Imagem005.jpg\" width=\"".$newWidth."\" height=\"".$newHeight."\"/>";
In your case, the img tag looks like this:
echo '<img src="data:image/jpeg;base64,'.base64_encode( $books->Image ).'" height='.$newHeight.' width='.$newWidth.'/>';
On the other hand, leaving PHP aside, just indicate the width in the img tag that browsers automatically calculate the height.