Click to See Complete Forum and Search --> : How should I resize any .bmp image using php script


sandeep_sandy
12-19-2006, 03:19 AM
How should I resize any .bmp image using php script

chrisranjana
12-19-2006, 03:52 AM
http://www.php.net/manual/en/ref.image.php#63689



<?php
function imagebmp ($im, $fn = false)
{
if (!$im) return false;

if ($fn === false) $fn = 'php://output';
$f = fopen ($fn, "w");
if (!$f) return false;

//Image dimensions
$biWidth = imagesx ($im);
$biHeight = imagesy ($im);
$biBPLine = $biWidth * 3;
$biStride = ($biBPLine + 3) & ~3;
$biSizeImage = $biStride * $biHeight;
$bfOffBits = 54;
$bfSize = $bfOffBits + $biSizeImage;

//BITMAPFILEHEADER
fwrite ($f, 'BM', 2);
fwrite ($f, pack ('VvvV', $bfSize, 0, 0, $bfOffBits));

//BITMAPINFO (BITMAPINFOHEADER)
fwrite ($f, pack ('VVVvvVVVVVV', 40, $biWidth, $biHeight, 1, 24, 0, $biSizeImage, 0, 0, 0, 0));

$numpad = $biStride - $biBPLine;
for ($y = $biHeight - 1; $y >= 0; --$y)
{
for ($x = 0; $x < $biWidth; ++$x)
{
$col = imagecolorat ($im, $x, $y);
fwrite ($f, pack ('V', $col), 3);
}
for ($i = 0; $i < $numpad; ++$i)
fwrite ($f, pack ('C', 0));
}
fclose ($f);
return true;
}
?>

sandeep_sandy
12-19-2006, 03:59 AM
Thanx Crisranjana .

chrisranjana
12-19-2006, 04:12 AM
NO problem , It's a pleasure.

sandeep_sandy
12-19-2006, 04:20 AM
I Want to to resize image by 200*200 where should I mention it at biHeight and
biwithd and where should i echo (display) that image.