PDA

View Full Version : php dimensions image



Drunken
September 30th, 2003, 08:20 AM
Heya!

I have an option to upload images, but I want to control if images have widht < 300 and height < 220. How can i do that?

thks

awligon
September 30th, 2003, 08:40 AM
no, there is no way to read the image attributes on upload. You can however, limit the file size or type.

On display, you can force a resize if you want to constrain it to <300 x 220. I'm assuming you want to display pics w/o running the risk of it ****ing up your layout?.? Use an iframe to display with automatic scrolling and a fixed size.



<?php
$pic = some_value;

echo "
<table>
<tr><td><iframe src=pics/". $pic .", scrolling=auto, height=220, width=300, frameBorder=0></iframe></td></tr>
</table>
";
?>

Jubba
September 30th, 2003, 08:54 AM
Actually it is possible (with a work around), but I don't have time right now to type up the code. I'll have it for you later today. :)

xEnOn
September 30th, 2003, 09:33 AM
I think Vash is right...Not sure but you can try this...


<?php
$imgsizestuff = getimagesize("myuploadfiledir/".$picname);
if($imgsizestuff[0] < 300 || $imgsizestuff[1] < 220) {
print "I am sorry dude...no big pic";
} else {
//upload the pic then
}
?>


I haven't test the code yet...but i think u can somehow get the idea...convert it into a function if u want to be conveniece...

Drunken
September 30th, 2003, 10:15 AM
thks everyone for help :)

I will test your sugestions ;)

xEnOn
September 30th, 2003, 11:36 AM
ur welcome... ;)

awligon
September 30th, 2003, 03:30 PM
good call