Qassia Qassia Canada
Qassia Global > Qassia Canada > hotnoob's Intel > How to Autosize Images with php
Intel Contributor
This intel was added by hotnoob

Intel Classification
This intel has been classified as Existing Authored Content, which means it was authored by the contributor, and first appeared on the contributor's blog or website.

Intel Calendar
December, 2008
1234567
891011121314
15161718192021
22232425262728
293031

January, February, March, April, May, June, July, August, September, October, November, December

Sign Up!
Not a member yet? You're missing out on one of the most powerful website promotion resources on the web. Sign up and join the party.

About Qassia
Find out more about Qassia by reading our About Us page, if you haven't done so already. Or you could skip straight to the Sign Up form.

PRINT THIS INTEL EMAIL THIS INTEL

How to Autosize Images with php

The simple PHP function will show you how to create an auto-sizing imaging system, which is especially handy when users are uploading their own images that may be a 1000 meters wide and high; it prevents people from destroying the layout to your site.
writePicture
Code:
function writePicture($image, $maxwidth, $maxheight)
{
if($image !== "")
{
list($width, $height, $type, $attr) = getimagesize($image);
if($width > $maxwidth)
{
$constant = $maxwidth/$width;
$width = $constant * $width;
$height = $constant * $height;
}
if($height > $height)
{
$constant = $maxheight/$height;
$width = $constant * $width;
$height = $constant * $height;
}
echo"<img src=\"$image\" width=\"$width\" height=\"$height\" border=\"0\">";
}
else
{
if($maxwidth < 1){ $maxwidth = 100; } if($maxheight < 1) { $maxheight = 100;}
echo"<img src=\"images/pages/missingpic.png\" width=\"$maxwidth\" height=\"$maxwidth\" border=\"0\">";
}
}

A Noobs World © 2007-2008

Copyright Notice: All Rights Reserved.

Add to Facebook Digg Add to Mixx Add to Reddit Add to StumbleUpon
Added by hotnoob on April 2, 4:47 AM.

PLEASE VISIT THE CONTRIBUTOR'S WEBSITE
A Noobs World
A free social optimizer
anoobsworld.info

Rate This Intel

Please login or sign up to rate this intel.

Comments

Please login or sign up to add a comment.





Crawled [11/30] - We promised all users participating in the Sticker Mania Promo ...



ABOUT | FAQ | PRESS RELEASES | HELP | CONTACT
USAGE POLICY | PRIVACY POLICY

Copyright 2008 Qassia. All Rights Reserved.

Username:
Password:
No account? Sign up.
Lost password? Retrieve.

In Directory
Internet + Computers