/    Sign up×
Community /Pin to ProfileBookmark

How should I resize any .bmp image using php script

How should I resize any .bmp image using php script

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chrisranjanaDec 19.2006 — http://www.php.net/manual/en/ref.image.php#63689


<i>
</i>&lt;?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) &amp; ~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 &gt;= 0; --$y)
{
for ($x = 0; $x &lt; $biWidth; ++$x)
{
$col = imagecolorat ($im, $x, $y);
fwrite ($f, pack ('V', $col), 3);
}
for ($i = 0; $i &lt; $numpad; ++$i)
fwrite ($f, pack ('C', 0));
}
fclose ($f);
return true;
}
?&gt;

[/quote]
Copy linkTweet thisAlerts:
@sandeep_sandyauthorDec 19.2006 — Thanx Crisranjana .
Copy linkTweet thisAlerts:
@chrisranjanaDec 19.2006 — NO problem , It's a pleasure.
Copy linkTweet thisAlerts:
@sandeep_sandyauthorDec 19.2006 — 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.
×

Success!

Help @sandeep_sandy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...