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; }
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; }
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()); }
<?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);