Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
private function NewImgResize($orig_img,$newxsize,$newysize,$filename)
{
//getimagesize returns array
// [0] = width in pixels
// [1] = height in pixels
// [2] = type
// [3] = img tag "width=xx height=xx" values
$orig_size = getimagesize($filename);
$newxsize = (int)$newxsize;
$newysize = (int)$newysize;
if(empty($newxsize) and empty($newysize)){
vmWarn('NewImgResize failed x,y = 0','NewImgResize failed x,y = 0');
return false;
}
$maxX = $newxsize;
$maxY = $newysize;
if ($orig_size[0]<$orig_size[1])
{
$newxsize = (int)$newysize * ($orig_size[0]/$orig_size[1]);
$adjustX = (int)($maxX - $newxsize)/2;
$adjustY = 0;
}
else
{
$newysize = (int) $newxsize / ($orig_size[0]/$orig_size[1]);
$adjustX = 0;
$adjustY = (int)($maxY - $newysize)/2;
}
/* Original code removed to allow for maxSize thumbnails
$im_out = ImageCreateTrueColor($newxsize,$newysize);
ImageCopyResampled($im_out, $orig_img, 0, 0, 0, 0,
$newxsize, $newysize,$orig_size[0], $orig_size[1]);
*/
// New modification - creates new image at maxSize
if( $this->maxSize )
{
if( function_exists("imagecreatetruecolor") )
$im_out = imagecreatetruecolor($maxX,$maxY);
else
$im_out = imagecreate($maxX,$maxY);
// Need to image fill just in case image is transparent, don't always want black background
$bgfill = imagecolorallocate( $im_out, $this->bg_red, $this->bg_green, $this->bg_blue );
if( function_exists( "imageAntiAlias" )) {
imageAntiAlias($im_out,true);
}
imagealphablending($im_out, false);
if( function_exists( "imagesavealpha")) {
imagesavealpha($im_out,true);
}
if( function_exists( "imagecolorallocatealpha")) {
$transparent = imagecolorallocatealpha($im_out, 255, 255, 255, 127);
}
//imagefill( $im_out, 0,0, $bgfill );
if( function_exists("imagecopyresampled") ){
ImageCopyResampled($im_out, $orig_img, $adjustX, $adjustY, 0, 0, $newxsize, $newysize,$orig_size[0], $orig_size[1]);
}
else {
ImageCopyResized($im_out, $orig_img, $adjustX, $adjustY, 0, 0, $newxsize, $newysize,$orig_size[0], $orig_size[1]);
}
}
else
{
if( function_exists("imagecreatetruecolor") )
$im_out = ImageCreateTrueColor($newxsize,$newysize);
else
$im_out = imagecreate($newxsize,$newysize);
if( function_exists( "imageAntiAlias" ))
imageAntiAlias($im_out,true);
imagealphablending($im_out, false);
if( function_exists( "imagesavealpha"))
imagesavealpha($im_out,true);
if( function_exists( "imagecolorallocatealpha"))
$transparent = imagecolorallocatealpha($im_out, 255, 255, 255, 127);
if( function_exists("imagecopyresampled") )
ImageCopyResampled($im_out, $orig_img, 0, 0, 0, 0, $newxsize, $newysize,$orig_size[0], $orig_size[1]);
else
ImageCopyResized($im_out, $orig_img, 0, 0, 0, 0, $newxsize, $newysize,$orig_size[0], $orig_size[1]);
}
return $im_out;
}
function NewImgResize($orig_img,$newxsize,$newysize,$filename)
{
//$newxsize; //new width
//$newysize; //new height
$orig_size = getimagesize($filename);
$heightRatio = $orig_size[1]/$newysize;
$widthRatio = $orig_size[0]/$newxsize;
if($heightRatio < $widthRatio){
$optimalRatio = $heightRatio;
} else {
$optimalRatio = $widthRatio;
}
$optimalHeight = $orig_size[1]/$optimalRatio;
$optimalWidth = $orig_size[0]/$optimalRatio;
$imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
$bgfill = imagecolorallocate( $imageResized, $this->bg_red, $this->bg_green, $this->bg_blue );
imagealphablending($imageResized, false);
imagesavealpha($imageResized,true);
$transparent = imagecolorallocatealpha($imageResized, 255, 255, 255, 127);
imagecopyresampled($imageResized, $orig_img, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $orig_size[0], $orig_size[1]);
$cropStartX = ( $optimalWidth / 2) - ( $newxsize /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newysize/2 );
$crop = $imageResized;
$imageResized = imagecreatetruecolor($newxsize , $newysize);
$bgfill = imagecolorallocate( $imageResized, $this->bg_red, $this->bg_green, $this->bg_blue );
imagealphablending($imageResized, false);
imagesavealpha($imageResized,true);
$transparent = imagecolorallocatealpha($imageResized, 255, 255, 255, 127);
imagecopyresampled($imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newxsize, $newysize , $newxsize, $newysize);
return $imageResized;
}
Так может ты нам всем подскажешь (с скриншотом) где изменять эту опцию? %) Спасибо!а в настройках вирта не то? Там же есть параметры "размер превью" и как делать превью... обрезать или ресайзить