Browse Source

MIRSPORTA-73 - Качество картинок. Ресамплинг

master
Alexander Demidov 11 years ago
parent
commit
f0313bd8f9
  1. 10
      Upload.class.php

10
Upload.class.php

@ -12,7 +12,7 @@ abstract class Upload
return $greagwar_image; return $greagwar_image;
} }
protected static function getFilePath($image)
public static function getFilePath($image)
{ {
return Config::get('PATH_WEB_ROOT') . DIRECTORY_SEPARATOR . $image->path . DIRECTORY_SEPARATOR . $image->filename; return Config::get('PATH_WEB_ROOT') . DIRECTORY_SEPARATOR . $image->path . DIRECTORY_SEPARATOR . $image->filename;
} }
@ -65,6 +65,12 @@ abstract class Upload
$size_parts = explode('x', $size); $size_parts = explode('x', $size);
self::saveImage($image_variant, $greagwar_image, $size_parts[0] ? : null, $size_parts[1] ? : null); self::saveImage($image_variant, $greagwar_image, $size_parts[0] ? : null, $size_parts[1] ? : null);
$image->variants[$size] = $image_variant; $image->variants[$size] = $image_variant;
if (Config::get('PYTHON_PIL_RESIZE')) {
$script_file_path = Config::get('PYTHON_PIL_RESIZE')->script_file_path;
ob_start();
exec($script_file_path . ' --width=' . $size_parts[0] . ' --height=' . $size_parts[1] . ' ' . self::getFilePath($image) . ' ' . self::getFilePath($image_variant));
ob_clean();
}
} }
/** /**
@ -85,7 +91,7 @@ abstract class Upload
} }
} }
$image->type = $greagwar_image->guessType(); $image->type = $greagwar_image->guessType();
$file_path = $greagwar_image->cacheFile($image->type, $quality = 95, true);
$file_path = $greagwar_image->cacheFile($image->type, $quality = 100, true);
$image->size = filesize($file_path); $image->size = filesize($file_path);
$path_parts = pathinfo($file_path); $path_parts = pathinfo($file_path);
$image->path = preg_replace('#^' . Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']); $image->path = preg_replace('#^' . Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']);

Loading…
Cancel
Save