resizeToBestFit() public method

Resizes image to best fit inside the given dimensions
public resizeToBestFit ( integer $max_width, integer $max_height, boolean $allow_enlarge = false ) : static
$max_width integer
$max_height integer
$allow_enlarge boolean
return static
コード例 #1
0
ファイル: LocalStorage.php プロジェクト: typerocket/laravel
 protected function makeThumb($file, MediaProvider $media)
 {
     $name = 'thumb-' . $media->file;
     $new = $media->path . '/' . $name;
     $image = new ImageResize($file);
     $image->resizeToBestFit(150, 150);
     $image->save(storage_path() . $new);
     return $name;
 }
コード例 #2
0
 private function uploadImage($file)
 {
     $destinationPath = public_path('img/wishes/');
     $filename = $this->makeImageNameUnique($file);
     $image = new ImageResize($file->getPathName());
     $image->resizeToBestFit(500, 500);
     $image->save($destinationPath . $filename, IMAGETYPE_JPEG);
     return $filename;
 }
コード例 #3
0
ファイル: Test.php プロジェクト: madisonmay/php-image-resize
 public function testResizeToBestFitNoEnlarge()
 {
     $image = $this->createImage(200, 100, 'png');
     $resize = new ImageResize($image);
     $resize->resizeToBestFit(250, 250);
     $this->assertEquals(200, $resize->getDestWidth());
     $this->assertEquals(100, $resize->getDestHeight());
 }
コード例 #4
0
ファイル: insertNewDevices.php プロジェクト: Basheir/AFix
<?php

include '../config.php';
$result = array('suc' => false, 'msg' => 'خطا :: حاول مرة اخرى', 'idMsg' => 3);
if (!trim($_POST['NameDevices'])) {
    $result['msg'] = 'قم باضافة نوع الجهاز';
    echo json_encode($result);
    exit;
}
include '../Class/ImageResize.php';
$ImgDir = IMAGEDEVICES . $_POST['ImageUrl'];
$ext = pathinfo($ImgDir, PATHINFO_EXTENSION);
$time = time() . '.' . $ext;
use Eventviva\ImageResize;
$image = new ImageResize($ImgDir);
$image->resizeToBestFit(300, 300);
$image->save(IMAGEDEVICES . $time);
$Mdata = array('NameDevices' => $db->escape($_POST['NameDevices']), 'ImageUrl' => $time);
//$db->where('ID', $_GET['ID']);
$infoList = $db->insert('typeDevices', $Mdata);
if ($db->count > 0) {
    $result = array('suc' => true, 'msg' => 'تمت العملية بنجاح', 'idMsg' => 1);
}
echo json_encode($result);