For the website I am building I need to resize some images to make web page loading lighter. I use this code:
list($width, $height, $type, $attr) = getimagesize($img_path);
$thumb = imagecreatetruecolor(50, 50 * $height/$width);
if($type == 2) $source = imagecreatefromjpeg($img_path);
if($type == 3) $source = imagecreatefrompng($img_path);
imagecopyresized($thumb, $source, 0, 0, 0, 0, 50, 50 * $height/$width, $width, $height);
Now I could save them on the sever to keep them ready whenever necessary but considering the little space I have available I would rather avoid.
So my question is: is there a way to create a "temporary" image from the code I already have and use it inside an <img>
tag?
For example <img src="$img_resized"/>
.