I am working on uploading a script image with PHP, I found that someone was suggesting and trying to modify it, however I ran into several problems.
I want to do the following: Detect the longest side of the image (for example, portrait or landscape) And then resize the image, with the longest side being 800 pixels and keep the aspect ratio.
Here is the code that I still have. For landscape images, it works great, but with portrait images it distorts them like crazy. PS. I am making an enlarged image as well as a thumbnail.
list($width,$height)=getimagesize($uploadedfile);
if($width > $height){
$newwidth=800;
$newheight=($height/$width)*$newwidth;
$newwidth1=150;
$newheight1=($height/$width)*$newwidth1;
} else {
$newheight=800;
$newwidth=($height/$width)*$newheight;
$newheight1=150;
$newwidth1=($height/$width)*$newheight;
}
$tmp=imagecreatetruecolor($newwidth,$newheight);
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
source
share