Guest User

Untitled

a guest
Jan 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. $list = getimagesize($imagePath);
  2. $width = $list[0];
  3. $height = $list[1];
  4.  
  5. $height = round(($height * $width) / $width);
  6.  
  7. list($Width, $Height) = getimagesize($row["img_file"]);
  8.  
  9. if(($Width > $Height) && ($Width > 115))
  10. {
  11. $Height = ceil(($Height / $Width) * 115) ;
  12. $Width = 115;
  13. }
  14. elseif(($Height > $Width) && ($Height > 115))
  15. {
  16. $Width = ceil(($Width / $Height)* 115);
  17. $Height = 115;
  18. }
  19. elseif(($Height > 115) && ($Height == $Width))
  20. {
  21. $Height = 115;
  22. $Width = 115;
  23. }
  24.  
  25. if ($extension == "png")
  26. {
  27. $image = imagecreatefrompng($URLofImage)or die("Width Of Image: ".$widthofImage." Height Of Image: ".$heightofImage." Height: ".$height." Width: ".$width);
  28. $image_p = imagecreatetruecolor($widthofImage, $heightofImage)or die("Width Of Image: ".$widthofImage." Height Of Image: ".$heightofImage." Height: ".$height." Width: ".$width);
  29. imagealphablending($image_p, false);
  30. $color = imagecolorallocatealpha($image_p, 0, 0, 0, 0);
  31. imagesavealpha($image_p, true);
  32. list($width, $height) = getimagesize($URLofImage);
  33.  
  34. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $widthofImage, $heightofImage, $width, $height);
  35. imagepng($image_p, "./images/thumbs/".$name, 9);
  36.  
  37. return ("./images/thumbs/".$name);
  38. }
  39.  
  40. $max_width = 115;
  41. $max_height = 115;
  42.  
  43. list($width, $height) = getimagesize($imagePath);
  44. $ratioh = $max_height/$height;
  45. $ratiow = $max_width/$width;
  46. $ratio = min($ratioh, $ratiow);
  47.  
  48. // New dimensions
  49. $width = intval($ratio * $width);
  50. $height = intval($ratio * $height);
  51.  
  52. $max_height = 115;
  53. if ($height > $max_height)
  54. {
  55. $scale = $max_height / $height;
  56. $height = intval($height * $scale);
  57. $width = intval($width * $scale);
  58. }
  59.  
  60. $max_size = 115;
  61. if (max($height, $width) > $max_size)
  62. {
  63. $scale = $max_size / max($height, $width);
  64. $height = intval($height * $scale);
  65. $width = intval($width * $scale);
  66. }
  67.  
  68. <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