You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
989 B

  1. <?php
  2. abstract class UploadHelper
  3. {
  4. public static function imageCompareAspectRatio($proportion, $file_path)
  5. {
  6. if (file_exists($file_path) && is_readable($file_path) && is_file($file_path)) {
  7. if ($imagesize = getimagesize($file_path)) {
  8. $proprtion_parts = explode('x', $proportion);
  9. if ($proprtion_parts[0] / $proprtion_parts[1] === $imagesize[0] / $imagesize[1]) {
  10. return true;
  11. }
  12. }
  13. }
  14. return false;
  15. }
  16. public static function imageCompareSize($size, $file_path)
  17. {
  18. if (file_exists($file_path) && is_readable($file_path) && is_file($file_path)) {
  19. if ($imagesize = getimagesize($file_path)) {
  20. $size_parts = explode('x', $size);
  21. if ($imagesize[0] == $size_parts[0] && $imagesize[1] == $size_parts[1]) {
  22. return true;
  23. }
  24. }
  25. }
  26. return false;
  27. }
  28. }