Forum Moderators: coopster
<?php
$msg_text=preg_replace("/img /", "img width=25\% height=25\% ", $msg_text);
echo $msg_text; ?>
Any ideas?
I can see your problem ... I also once had to resort to resizing an image with the dimension attributes of the image tag, and boy it was ugly!
I have an old image resizing script somewhere ... I'll see if I can dig it up for you. In the meantime, I suggest googling "PHP image resizing". You're likely to get tons of results, and I'm sure a few will be fairly helpful. Keep in mind, resizing images with php isnt always that great, especially when dealing with different image types.
I'm learning PHP and not so long ago did this example.
<? php
header("content-type: image/png");
$src_img = imagecreatefrompng("sample.png");
$srcsize = getimagesize("sample.png");
$dst_x = $srcsize[0] / 1.5;
$dst_y = $srcsize[1] / 1.5;
$dst_img = imagecreatetruecolor($dst_x, $dst_y);
Imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dst_x, $dest_y, $srcsize[0], $srcsize[1]);
imagepng($dst_img);
imagedestroy($src_img);
imagedestroy($dest_img);
?>
I'm sure you can test the $srcsize for aspect ratio and script the $dst_size accordingly to keep the aspect ratio for presentation purposes.
Hope this helps
Dave