adaptation pour minio
This commit is contained in:
@ -38,7 +38,7 @@ class CropController extends AbstractController
|
||||
{
|
||||
// Récupération de l'image à cropper
|
||||
$file=$request->query->get('file');
|
||||
$large_image_location = "uploads/$type/$file";
|
||||
$large_image_location=$this->minio->download($type."/".$file,$type."/".$file,true);
|
||||
|
||||
// Récupérer les tailles de l'image
|
||||
$width = $this->getWidth($large_image_location);
|
||||
@ -72,13 +72,14 @@ class CropController extends AbstractController
|
||||
$ratio="1:1";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($max_height>0) {
|
||||
$scale = $max_height/$height;
|
||||
if(($width*$scale)>$max_width) {
|
||||
$scale = $max_width/$width;
|
||||
}
|
||||
$this->resizeImage($large_image_location,$width,$height,$scale);
|
||||
$this->minio->upload($large_image_location,$type."/".$file,false);
|
||||
}
|
||||
else $scale=1;
|
||||
|
||||
@ -103,12 +104,12 @@ class CropController extends AbstractController
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
// Récupération des valeurs du formulaire
|
||||
$data = $form->getData();
|
||||
$thumb_image_location = "uploads/$type/thumb_".$file;
|
||||
$tmpdir=$this->appKernel->getProjectDir()."/var/tmp";
|
||||
$thumb_image_location = "$tmpdir/$type/thumb_".$file;
|
||||
$cropped = $this->resizeThumbnailImage($thumb_image_location, $large_image_location,$data["ws"],$data["hs"],$data["xs"],$data["ys"],$scale);
|
||||
|
||||
// Dépot des fichiers sur minio
|
||||
$this->minio->upload($large_image_location,$large_image_location,true);
|
||||
$this->minio->upload($thumb_image_location,$thumb_image_location,true);
|
||||
$this->minio->upload($thumb_image_location,$type."/thumb_".$file,false);
|
||||
|
||||
$submited=true;
|
||||
}
|
||||
@ -186,10 +187,13 @@ class CropController extends AbstractController
|
||||
|
||||
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
|
||||
$imageType = image_type_to_mime_type($imageType);
|
||||
|
||||
$newImageWidth = ceil($width * $scale);
|
||||
$newImageHeight = ceil($height * $scale);
|
||||
$newImageWidth=900;
|
||||
$newImageHeight=900;
|
||||
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
|
||||
|
||||
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
$source=imagecreatefromgif($image);
|
||||
@ -197,6 +201,7 @@ class CropController extends AbstractController
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
dump("here");
|
||||
$source=imagecreatefromjpeg($image);
|
||||
break;
|
||||
case "image/png":
|
||||
@ -204,7 +209,9 @@ class CropController extends AbstractController
|
||||
$source=imagecreatefrompng($image);
|
||||
break;
|
||||
}
|
||||
imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
|
||||
|
||||
$ok=imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
|
||||
|
||||
switch($imageType) {
|
||||
case "image/gif":
|
||||
imagegif($newImage,$thumb_image_name);
|
||||
@ -212,14 +219,16 @@ class CropController extends AbstractController
|
||||
case "image/pjpeg":
|
||||
case "image/jpeg":
|
||||
case "image/jpg":
|
||||
imagejpeg($newImage,$thumb_image_name,90);
|
||||
dump($thumb_image_name);
|
||||
imagejpeg($newImage,$thumb_image_name,100);
|
||||
break;
|
||||
case "image/png":
|
||||
case "image/x-png":
|
||||
imagepng($newImage,$thumb_image_name);
|
||||
break;
|
||||
}
|
||||
chmod($thumb_image_name, 0640);
|
||||
|
||||
chmod($thumb_image_name, 0640);
|
||||
return $thumb_image_name;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user