important создание изображения при наличии необходимых для этого условий

MIRSPORTA-885 Группировка фотографий
This commit is contained in:
2015-12-23 03:52:28 +03:00
parent 35c914f826
commit 8c82ae7ac4
2 changed files with 21 additions and 0 deletions

View File

@ -109,7 +109,9 @@ abstract class Upload
} else {
$greagwar_image = self::getGreagwarImage($tmp_file_path);
}
$image->type = $greagwar_image->guessType();
if (!Image::getIsSubClass($image)) {
if ( !( ImageVariant::getIsClass( $image ) ) && Image::getIsSubClass( $image ) ) {
$greagwar_image->resize( $width, $height, 0xffffff, $force = false, $rescale = false, $crop = true );
@ -117,8 +119,11 @@ abstract class Upload
$greagwar_image->resize( $width, $height, 0xffffff, $force = false, $rescale = false, $crop = false );
}
}
$hash = $greagwar_image->getHash($image->type, $quality = 100);
$file_path = $greagwar_image->generateFileFromhash($hash) . '.' . $image->type;
if (Image::getIsSubClass($image)) {
if (is_uploaded_file($tmp_file_path)) {
move_uploaded_file($tmp_file_path, $file_path);
@ -128,17 +133,24 @@ abstract class Upload
} else {
if (\Majestic\Config::get('PYTHON_PIL_RESIZE')) {
$script_file_path = \Majestic\Config::get( 'PYTHON_PIL_RESIZE' )->script_file_path;
$pil_options = isset( \Majestic\Config::get( 'PYTHON_PIL_RESIZE' )->pil_options ) ? ' ' . implode( ' ', \Majestic\Config::get( 'PYTHON_PIL_RESIZE' )->pil_options ) : '';
// ob_start();
$code = null;
$command = $script_file_path
. ( ( $width ) ? ' --width=' . $width : '' )
. ( ( $height ) ? ' --height=' . $height : '' )
. $pil_options
. ' ' . $tmp_file_path
. ' ' . $file_path;
ob_start();
passthru( 'exec 2>&1; ' . $command, $code );
if ($code !== 0) {
throw new \ErrorException('Command PYTHON_PIL_RESIZE exit with code "' . $code . '": ' . $command . PHP_EOL . 'Std out: ' . ob_get_clean() );
}
@ -149,10 +161,15 @@ abstract class Upload
}
}
}
$path_parts = pathinfo($file_path);
$image->path = preg_replace('#^' . \Majestic\Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']);
$image->filename = $path_parts['basename'];
self::defineSizeWidthAndHeight($image);
unset($greagwar_image);
}