Jump to content

PHP / Photo question


xcandiottix

Recommended Posts

I am working on a new project in which people can upload a photo to the site and the photo will be posted back up on a browse page.

My question is, if someone submits a 300 w x 500 h picture, can php figure that out so pictures are no taller then 400 and no wider then 400? So in this case, php would scale the 300x500 picture proportionately down to 400 tall. I don't want to set an absolute dimension to avoid pictures being distorted but at the same time down want 2000 x 3000 images popping up.

 

Thanks much,

k.candiotti

Link to comment
https://forums.phpfreaks.com/topic/196946-php-photo-question/
Share on other sites

It's pointless to list code without you looking through the documentation or examples first on how to handle these things.

 

If you're wanting exact sizes, Calculate the aspect ratio:

$aspect = ($width / $height);
$towidth = (400 / $aspect);

 

Therefor, the new width will be exactly the same proportion to the height, but the height will always be 400. There'll be no distortion.

Link to comment
https://forums.phpfreaks.com/topic/196946-php-photo-question/#findComment-1033994
Share on other sites

 

$aspect = ($width / $height);
$towidth = (400 / $aspect);

 

Therefor, the new width will be exactly the same proportion to the height, but the height will always be 400. There'll be no distortion.

 

That's what I was getting at. I already saw everything on how to get pictures up via php, etc. But, I wasn't sure what math was involved. I read up on getimagesize() but wasn't sure what to do with that next.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/196946-php-photo-question/#findComment-1034016
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.