Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $list = getimagesize($imagePath);
- $width = $list[0];
- $height = $list[1];
- $height = round(($height * $width) / $width);
- list($Width, $Height) = getimagesize($row["img_file"]);
- if(($Width > $Height) && ($Width > 115))
- {
- $Height = ceil(($Height / $Width) * 115) ;
- $Width = 115;
- }
- elseif(($Height > $Width) && ($Height > 115))
- {
- $Width = ceil(($Width / $Height)* 115);
- $Height = 115;
- }
- elseif(($Height > 115) && ($Height == $Width))
- {
- $Height = 115;
- $Width = 115;
- }
- if ($extension == "png")
- {
- $image = imagecreatefrompng($URLofImage)or die("Width Of Image: ".$widthofImage." Height Of Image: ".$heightofImage." Height: ".$height." Width: ".$width);
- $image_p = imagecreatetruecolor($widthofImage, $heightofImage)or die("Width Of Image: ".$widthofImage." Height Of Image: ".$heightofImage." Height: ".$height." Width: ".$width);
- imagealphablending($image_p, false);
- $color = imagecolorallocatealpha($image_p, 0, 0, 0, 0);
- imagesavealpha($image_p, true);
- list($width, $height) = getimagesize($URLofImage);
- imagecopyresampled($image_p, $image, 0, 0, 0, 0, $widthofImage, $heightofImage, $width, $height);
- imagepng($image_p, "./images/thumbs/".$name, 9);
- return ("./images/thumbs/".$name);
- }
- $max_width = 115;
- $max_height = 115;
- list($width, $height) = getimagesize($imagePath);
- $ratioh = $max_height/$height;
- $ratiow = $max_width/$width;
- $ratio = min($ratioh, $ratiow);
- // New dimensions
- $width = intval($ratio * $width);
- $height = intval($ratio * $height);
- $max_height = 115;
- if ($height > $max_height)
- {
- $scale = $max_height / $height;
- $height = intval($height * $scale);
- $width = intval($width * $scale);
- }
- $max_size = 115;
- if (max($height, $width) > $max_size)
- {
- $scale = $max_size / max($height, $width);
- $height = intval($height * $scale);
- $width = intval($width * $scale);
- }
- <img alt='image alt' src='imagesrc' style='max-width:115px; max-height:115px; height:auto; width:auto;' />
Add Comment
Please, Sign In to add comment