/** * @param Utils\Image|string $sourceFile * @param string $name * @param string $resolution * @param int $method * @return ImagePath */ public function saveFile($sourceFile, $name, $resolution, $method) { $filename = $this->path->getFilesystem($name, $resolution, $method); Utils\FileSystem::createDir(dirname($filename)); if ($sourceFile instanceof Utils\Image) { $resolutionArray = explode('x', $resolution); $sourceFile->resize($resolutionArray[0], $resolutionArray[1], (int) $method)->save($filename); } elseif (!$this->download->save($sourceFile, $filename)) { throw new ImageManager\RemoteFileDoesNotExistsException($sourceFile); } return new ImagePath($this->getPathUrl($name, $resolution, $method), $filename); }
/** * @param Utils\Image $image * @param string $path * @param string $extension * @return Image */ public function saveImage(Utils\Image $image, $path, $extension) { do { $relativePath = self::addSlashPath($path) . md5(microtime()) . '.' . strtolower($extension); $filename = $this->path->getSourceDir($relativePath); } while (is_file($filename)); if ($this->maxSize) { $image->resize($this->maxSize['width'], $this->maxSize['height'], Utils\Image::SHRINK_ONLY); } Utils\FileSystem::createDir(dirname($filename)); $image->save($filename); return new Image($this->path->getSourceDir(''), $relativePath); }
/** * @param $form * @param $values */ public function uploadImgFormSucceeded($form, $values) { $values = $form->getValues(); foreach ($values->img as $img) { // ActiveRow if ($img->isOk()) { $row = $this->imagesRepository->findAll()->insert(array('users_id' => $this->user->id, 'title' => $photoName = Strings::webalize($img->getName(), '.'), 'origin' => 'noSet', 'created_at' => new \DateTime())); $photo = Image::fromFile($img); $photoID = $row->getPrimary(); $photoX = $photo->height; $photoY = $photo->width; $path = __DIR__ . '/../../../web/images/' . $photoID; //mkdir('/var/www/m/' . $photoID, 0755, true); //mkdir('/var/www/skeleton/web/images/aaannn', 0755, true); if ($photoX > 102 or $photoY > 768) { $photo->resize(1024, 768, Image::SHRINK_ONLY); } mkdir($path, 0755, TRUE); $photo->save($path . '/' . $photoName); //$photoXGA = $photo->resize(1024, 768, Image::SHRINK_ONLY); //$photoSVGA->resize(800, 600, Image::SHRINK_ONLY); //$photoSVGA->resize(800, 600, Image::SHRINK_ONLY); //$imgName = $img->name; $this->flashMessage($this->translator->translate('ui.your-image-has-been-sent'), 'alert alert-success'); } } }
protected function createWeb() { Helpers::purge($this->wwwDir); Helpers::purge($this->wwwDir . '/images'); $image = Image::fromBlank(500, 500); $image->save($this->wwwDir . '/images/image.jpg'); }
public function uploadProductPhotos($images, $id_product) { $product = $this->database->findById('product', $id_product); if ($product) { // projedu vsechny fotografie foreach ($images as $img) { // priprava pro vlozeni do db $image = $this->prepareImageForUpload($img); $values['name'] = $this->generateHash(); $values['extension'] = $image['extension']; $values['id_product'] = $product->id; $values['added'] = $this->now; // upravy obrazku, zmena velikosti a dostreni $img_tmp = Nette\Utils\Image::fromFile($img); if ($img_tmp->width > 800) { $img_tmp->resize(800, null); } // w = 800px, h = auto $img_tmp->sharpen(); // doostreni obrazku // vlozeni fotografie do db $row = $this->database->insert('image', $values); // upload fotografie na server $img->move($this->root_img_dir . 'products/' . $product->id . '_' . $row->id . '_' . $values['name'] . '.' . $values['extension']); } } }
public function actionImage() { if (substr($this->url, 0, 7) === self::DIRECTORY_CACHE . '/') { $this->cached = true; $this->url = substr($this->url, 7); } if (($entity = $this->fileRepository->findOneBy(array('path' => $this->url))) === null) { throw new \Nette\Application\BadRequestException(sprintf('File \'%s\' does not exist.', $this->url)); } $image = Image::fromFile($entity->getFilePath()); $this->session->close(); // resize if ($this->size && $this->size !== 'default') { if (strpos($this->size, 'x') !== false) { $format = explode('x', $this->size); $width = $format[0] !== '?' ? $format[0] : null; $height = $format[1] !== '?' ? $format[1] : null; $image->resize($width, $height, $this->format !== 'default' ? $this->format : Image::FIT); } } if (!$this->type) { $this->type = substr($entity->getName(), strrpos($entity->getName(), '.')); } $type = $this->type === 'jpg' ? Image::JPEG : $this->type === 'gif' ? Image::GIF : Image::PNG; $file = sprintf('%s/%s/%s/%s/%s/%s', $this->cacheDir, self::DIRECTORY_CACHE, $this->size, $this->format, $this->type, $entity->getPath()); $dir = dirname($file); umask(00); @mkdir($dir, 0777, true); $image->save($file, 90, $type); $image->send($type, 90); }
private function loadImages() { $imageDir = WWW_DIR . "/layouts/" . $this->name . "/images/"; $i = 0; if (is_dir($imageDir)) { $dirs_or_files = array_diff(scandir($imageDir), array('.', '..')); foreach ($dirs_or_files as $dir_or_file) { if (is_file($imageDir . "/" . $dir_or_file)) { $image = Image::fromFile($imageDir . $dir_or_file); // ignore images bigger than XXX px if ($image->getWidth() <= 800) { // first image is main image if ($i === 0) { $this->mainImage = "../layouts/" . $this->name . "/images/" . $dir_or_file; // other images } else { $this->images[] = "../layouts/" . $this->name . "/images/" . $dir_or_file; } $i++; } else { unset($image); } } } } else { throw new Exception("'" . $this->path . "' is not a directory!"); } }
public function renderPreview($image, $width = null, $height = null, $sharpen = false) { //nazev preview $previewName = explode('.', $image); $postfix = $previewName[count($previewName) - 1]; unset($previewName[count($previewName) - 1]); $previewName = implode('.', $previewName) . '_' . $width . '_' . $height . '.' . $postfix; //slouzim routu do normalniho tvaru $prefixDir = substr($image, 0, 4); if (!is_dir($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir)) { mkdir($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir); chmod($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir, 0777); } if (file_exists($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir . '/' . $previewName)) { $image = Image::fromFile($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir . '/' . $previewName); } else { $image = Image::fromFile($this->context->parameters['wwwDir'] . '/images/upload/' . $prefixDir . '/' . $image); $image->resize($width, $height); if ($sharpen) { $image->sharpen(); } $image->save($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir . '/' . $previewName); } $image->send(Image::PNG); $this->terminate(); }
function dropUploadFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { if (!empty($_FILES)) { $ds = DIRECTORY_SEPARATOR; $storeFolder = 'media/' . $form->values->pages_id; \App\Model\IO::directoryMake(APP_DIR . $ds . $storeFolder, 0755); $tempFile = $_FILES['file']['tmp_name']; $realFile = $_FILES['file']['name']; $targetPath = APP_DIR . $ds . $storeFolder . $ds; $targetFile = $targetPath . $_FILES['file']['name']; move_uploaded_file($tempFile, $targetFile); chmod($targetFile, 0644); $fileSize = filesize($targetFile); $checkImage = $this->database->table("media")->where(array('name' => $realFile, 'pages_id' => $form->values->id)); // Thumbnail for images if (\App\Model\IO::isImage($targetFile)) { \App\Model\IO::directoryMake(APP_DIR . $ds . $storeFolder . $ds . 'tn', 0755); // thumbnails $image = \Nette\Utils\Image::fromFile($targetFile); $image->resize(400, 250, \Nette\Utils\Image::SHRINK_ONLY); $image->sharpen(); $image->save(APP_DIR . '/media/' . $form->values->pages_id . '/tn/' . $realFile); chmod(APP_DIR . '/media/' . $form->values->pages_id . '/tn/' . $realFile, 0644); } if ($checkImage->count() == 0) { $this->database->table("media")->insert(array('name' => $realFile, 'pages_id' => $form->values->pages_id, 'filesize' => $fileSize, 'file_type' => 1, 'date_created' => date("Y-m-d H:i:s"))); } else { echo "Nejsem reálný soubor"; } } exit; }
/** * @param IFile $file * @param string $path * @throws \Nette\Utils\UnknownImageFileException */ public function apply(IFile $file, $path) { $image = Image::fromFile($path); if ($image->getWidth() > $this->width || $image->getHeight() > $this->height || $this->resizeSmallPicture) { $image->resize($this->width, $this->height, $this->crop ? Image::EXACT : Image::FIT); } $image->save($path, 85); }
/** * @param \Nette\Http\IRequest * @param \Nette\Http\IResponse */ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) { if ($this->image instanceof Nette\Utils\Image) { $image = $this->image; } else { $image = Nette\Utils\Image::fromFile($this->image); } $image->send(); }
$values->avatar = $this->_uploadTitleImage($values->avatar); if (is_file("www/" . $this->avatar_path . $values->old_avatar)) { unlink($this->www_dir . "/www/" . $this->avatar_path . $values->old_avatar); } $this->hlavne_menu->uloz(["avatar" => $values->avatar], $values->id); } else { throw new Database\DriverException('Pre titulný obrázok nebol použitý obrázok a tak nebol uložený!' . $e->getMessage()); } } else { throw new Database\DriverException('Pri pokuse o uloženie došlo k chybe! Pravdepodobná príčina je:' . $this->presenter->upload_error[$values->avatar->error] . $e->getMessage()); } } catch (Database\DriverException $e) {
/** * @param Entities\Person $person * @param Nette\Utils\Image $image * @param string $source Zdroj obrazku (napr. Flick, atd.) * @return boolean */ public function setPersonAvatar($person, $image, $source = NULL) { //odstranit puvodni obr vcetne nahledu $this->deletePersonAvatar($person); //vytvorit nahled a ulozit novy obr $imageName = $person->id . '_' . $person->getWebalizeName() . '.jpg'; $thumbnail = 'avatar' . '_' . $imageName; $resImg = $image->save($this->wwwDirUser . $imageName); if (!$resImg) { return FALSE; } if (empty($source)) { $source = NULL; } $myImage = new Entities\Image($imageName, $source); $myImage->thumbnail = $thumbnail; $person->setAvatar($myImage); $image->resize(100, NULL, \Nette\Utils\Image::SHRINK_ONLY); $resImg2 = $image->save($this->wwwDirUser . $thumbnail, 50); return $resImg && $resImg2; }
private function storePhotos($values) { $now = DateTimeUtils::getNow(); $filepath = Strings::webalize(Passwords::hash($now->format(DateTimeUtils::DB_DATETIME_FORMAT))) . $values->filepath->name; $photo = Image::fromFile($values->filepath); $photo->resize(748, 490, Image::STRETCH); $photo->save("img/articles/" . $filepath); $photo->resize(359, 235, Image::STRETCH); $photo->save("img/articles/midiatures/" . $filepath); $photo->resize(130, 130, Image::STRETCH); $photo->save("img/articles/miniatures/" . $filepath); return $filepath; }
/** * @param string $name * @param string $resolution * @param int $method * @throws ImageManager\ResolutionIsNotAllowedException * @throws ImageManager\RemoteFileDoesNotExistsException * @return bool */ public function send($name, $resolution, $method) { $this->checkResolution($resolution); $imagePath = $this->createImagePath($name, $resolution, $method); if ($imagePath->fs) { Utils\Image::fromFile($imagePath->fs)->send(); return TRUE; } elseif ($imagePath->url) { Utils\Image::fromString($this->download->loadFromUrl($imagePath->url))->send(); return TRUE; } return FALSE; }
private function getColor($hex) { if (strlen($hex) == 3) { $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); } else { $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); } return Image::rgb($r, $g, $b); }
/** * @param Service $thumbator * @param string $original * @param string $thumb * @param int $width * @param int $height * @param int $method * @return void */ public function resize($thumbator, $original, $thumb, $width, $height, $method) { try { $image = Image::fromFile($original); } catch (UnknownImageFileException $e) { throw new InvalidStateException("Image: loading image error!"); } // Create dirs Helpers::mkdir(dirname($thumb)); // Resize image $image->resize($width, $height, $method); // Save thumb $image->save($thumb); }
/** * @param InputInterface $input * @param \SplFileInfo $file * @return bool */ private function resizeImage(InputInterface $input, \SplFileInfo $file) { $size = $input->getOption('size'); $path = $file->getPathname(); $image = \Nette\Utils\Image::fromFile($path, $format); if ($image->getWidth() <= $size && $image->getHeight() <= $size) { return TRUE; } $image->resize($size, $size, $image::FIT | $image::SHRINK_ONLY); if ($input->getOption('backup')) { copy($path, $path . '.backup'); } return $image->save($path, $input->getOption('quality'), $format); }
public function formPhotoSubmitted(Nette\Application\UI\Form $form) { $fd = $form->getValues(); foreach ($fd->img as $img) { $name = date("Y_m_d_H_i_s_") . Nette\Utils\Random::generate(10); $img = \Nette\Utils\Image::fromFile($img); $img->save("./data/photo/original/" . $name . ".jpg"); $img->resize(200, 200); create_square_image("./data/photo/original/" . $name . ".jpg", "./data/photo/thumb/" . $name . ".jpg", 200); // $img->save("./data/photo/thumb/". $name.".jpg"); } $this->flashMessage("Moc děkujem za fotky :-)", "success"); $this->redirect("this"); }
/** * Get Image from source * @param mixed $source Source of image * @return array|NULL ["image" => Nette\Utils\Image, "filename" => string] */ public function getImageInfo($source) { if (is_string($source)) { foreach ($this->dirs as $dir) { if (file_exists($dir . $source)) { $path_parts = pathinfo($source); $filename = $path_parts['filename']; return ["image" => Image::fromFile($dir . $source), "filename" => $filename, "lazy" => TRUE, "params" => ["dir" => $path_parts['dirname'], "ext" => $path_parts['extension']]]; } elseif (Validators::isUrl($source)) { return ["image" => Image::fromFile($source), "filename" => basename($source)]; } } } }
/** * @param Service $thumbator * @param string $original * @param string $filename * @param int $width * @param int $height * @param int $method * @return string */ public function placehold($thumbator, $original, $filename, $width, $height, $method) { try { $data = @file_get_contents(sprintf($this->placeholder, $width, $height)); if ($data) { $image = Image::fromString($data); Helpers::mkdir(dirname($thumbator->config->getStorageDir() . DIRECTORY_SEPARATOR . $original)); $image->save($thumbator->config->getStorageDir() . DIRECTORY_SEPARATOR . $original); return $thumbator->create($original, $width, $height, $method); } } catch (\Exception $e) { // Silent.. } return sprintf($this->placeholder, $width, $height); }
/** * @return BaseForm */ public function build() { $this->addGroup('Registration'); $this->addText('username', 'Name:')->setRequired('Please enter your username.'); $this->addText('email', 'Email:')->setRequired('Please enter your email.')->addRule(Form::EMAIL, 'Check out email please'); $this->addPassword('password', 'Password:'******'Please enter your password.')->addRule(Form::PATTERN, 'Password must have more than 8 numerals and consists of numbers 0-9, lowercase or uppercase letters a-z or A-Z, underscore', '([0-9a-zA-Z_]){8}'); $this->addPassword('passwordRe', 'Repeat password:'******'Please enter your password once again.')->addRule(Form::EQUAL, 'Password missmatch', $this['password']); $this->addCheckbox('remember', 'Keep me signed in after registration'); /* reCaptcha : you should choose certen pictures $this->addReCaptcha('captcha') ->addRule(ReCaptchaControl\ReCaptchaControl::VALID, 'Prokažte prosím svou nerobotičnost.');*/ $this->addCaptcha('captcha')->addRule(Form::FILLED, "Rewrite text from image.")->addRule($this["captcha"]->getValidator(), 'Try it again.')->setLength(5)->setTextMargin(5)->setTextColor(Image::rgb(0, 0, 0))->setBackgroundColor(Image::rgb(214, 235, 249))->setImageHeight(50)->setImageWidth(0)->setExpire(10)->setFilterSmooth(false)->setFilterContrast(false)->useNumbers(true); // bool or void $this->addSubmit('submit', 'Sign in'); return $this; }
$form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setValidationScope(FALSE); return $form; } /** Spracovanie vstupov z formulara * @param Nette\Forms\Controls\SubmitButton $button Data formulara */ public function editSliderFormSubmitted($button) { $values = $button->getForm()->getValues(); $data = $this->slider->find($values->id); //Nacitanie editovanej polozky if ($values->zobrazenie_null) { $values->zobrazenie = NULL; } unset($values->zobrazenie_null); if ($this->slider_i['odkaz']) { $values->id_hlavne_menu = (int) $values->id_hlavne_menu > 0 ? (int) $values->id_hlavne_menu : NULL; if ($values->id_hlavne_menu !== NULL) { //Kontrola exzistencie id_hlavne_menu if ($this->hlavne_menu->find($values->id_hlavne_menu) == FALSE) { $button->addError('Zadali ste nesprávne číslo článku. Skúste znovu!'); return; } } } if ($values->subor && $values->subor->name != "") { if ($values->subor->isImage()) { $slider_dir = $this->wwwDir . "/www/files/slider/"; $finalFileName = $this->_imageFileName($slider_dir, $values->subor->getSanitizedName()); $image_name = $slider_dir . $finalFileName; $values->subor->move($image_name); $image = Image::fromFile($image_name); $image->resize($this->slider_i['x'], $this->slider_i['y'], Image::SHRINK_ONLY | Image::EXACT); $image->save($image_name, 80); if (is_file('www/files/slider/' . $data['subor'])) { unlink($slider_dir . $data['subor']); } $values->subor = $finalFileName; } else { $button->addError('Zadali ste nesprávne číslo článku. Skúste znovu!'); unset($values->subor); return; } } else { unset($values->subor); } try {
/** * * @param \Nette\Http\FileUpload $file * @return string */ private function getImageBase64(\Nette\Http\FileUpload $file) { $type = $file->getContentType(); $img = Image::fromFile($file); $img->resize(100, 100, Image::EXACT); $img_string = ""; switch ($type) { case 'image/png': $img_string = $img->toString(Image::PNG); break; case 'image/jpeg': $img_string = $img->toString(Image::JPEG); break; case 'image/gif': $img_string = $img->toString(Image::GIF); break; } return 'data:' . $type . ';base64,' . base64_encode($img_string); }
/** * vykresli obrazek * @param type $image nazev obrazku * @param type $width sirka * @param type $height vyska * @param type $sharpen zaostreni * @param type $exact presna velikost (oreze zbytek) */ public function renderPreview($image, $width = null, $height = null, $sharpen = false, $exact = true) { /*$this->getHttpResponse()->setExpiration(strtotime('+ 1 year', time())); $this->getHttpResponse()->setHeader('Pragma', 'cache');*/ //nazev preview $previewName = explode('.', $image); $postfix = $previewName[count($previewName) - 1]; unset($previewName[count($previewName) - 1]); $previewName = implode('.', $previewName) . '_' . $width . '_' . $height; if ($sharpen) { $previewName .= '_sharpen'; } if ($exact) { $previewName .= '_exact'; } $previewName .= '.' . $postfix; //slouzim routu do normalniho tvaru $prefixDir = substr($image, 0, 4); if (!is_dir($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir)) { mkdir($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir); chmod($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir, 0777); } if (file_exists($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir . '/' . $previewName)) { $this->getHttpResponse()->setHeader('Content-Type', 'image/png'); echo file_get_contents($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir . '/' . $previewName); exit; } else { $image = Image::fromFile($this->context->parameters['wwwDir'] . '/images/upload/' . $prefixDir . '/' . $image); if ($exact) { $image->resize($width, $height, Image::EXACT); } else { $image->resize($width, $height, Image::SHRINK_ONLY); } if ($sharpen) { $image->sharpen(); } $image->save($this->context->parameters['wwwDir'] . '/images/preview/' . $prefixDir . '/' . $previewName, 100, Image::JPEG); $image->send(Image::JPEG); } $this->terminate(); }
/** * @param string $imageName * @param string $imageFormatName * @throws BadRequestException */ public function __invoke($imageName, $imageFormatName) { $image = $this->imageProvider->findOneByName($imageName); if (!$image) { throw new BadRequestException('Image not found.', 404); } $imageFormat = $this->imageFormatProvider->findOneByName($imageFormatName); if (!$imageFormat) { throw new BadRequestException('Image format not found.', 404); } $originalImagePath = $this->storage->getPath($image); if (!file_exists($originalImagePath)) { \Tracy\Debugger::log(new \Nette\InvalidStateException('File not found in the storage.')); throw new BadRequestException('Image not found.', 404); } $path = $this->storage->getPath($image, $imageFormat); if (!file_exists($path)) { $this->storage->createFormatedImage($image, $imageFormat); } Image::fromFile($path)->send(); }
function uploadFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $fileDirectory = APP_DIR . '/media/' . $form->values->id; \App\Model\IO::directoryMake($fileDirectory, 0755); if (strlen($_FILES["the_file"]["tmp_name"]) > 1) { $imageExists = $this->database->table("media")->where(array('name' => $_FILES["the_file"]["name"], 'pages_id' => $form->values->id)); $fileName = $fileDirectory . '/' . $_FILES["the_file"]["name"]; \App\Model\IO::remove($fileName); copy($_FILES["the_file"]["tmp_name"], $fileName); chmod($fileName, 0644); if ($imageExists->count() == 0) { $this->database->table("media")->insert(array('name' => $_FILES["the_file"]["name"], 'pages_id' => $form->values->id, 'description' => $form->values->description, 'filesize' => filesize($fileDirectory . '/' . $_FILES["the_file"]["name"]), 'file_type' => 1, 'date_created' => date("Y-m-d H:i:s"))); } // thumbnails $image = \Nette\Utils\Image::fromFile($fileName); $image->resize(400, 250, \Nette\Utils\Image::SHRINK_ONLY); $image->sharpen(); $image->save(APP_DIR . '/media/' . $form->values->id . '/tn/' . $_FILES["the_file"]["name"]); chmod(APP_DIR . '/media/' . $form->values->id . '/tn/' . $_FILES["the_file"]["name"], 0644); } $this->redirect(this, array("id" => $form->values->id, "category" => $form->values->category)); }
/** * @return void */ protected function createThumb() { set_time_limit(1800); $finfo = new \SplFileInfo($this->src); $ext = Nette\Utils\Strings::lower($finfo->getExtension()); if ($ext === 'gif' and class_exists(\Imagick::class)) { $image = new \Imagick($this->src); $image = $image->coalesceImages(); foreach ($image as $frame) { if ($this->crop) { $frame->cropThumbnailImage($this->width, $this->height); } else { $frame->thumbnailImage($this->width, $this->height, TRUE); } $frame->setPage($this->width, $this->height, 0, 0); } $image = $image->deconstructImages(); $image->writeImages($this->desc, TRUE); } else { $image = Nette\Utils\Image::fromFile($this->src); $image->resize($this->width, $this->height, $this->crop ? Nette\Utils\Image::EXACT : Nette\Utils\Image::FIT); $image->save($this->desc); } }
/** * Saves photo * @param string $name * @return type */ private function savePhoto($name) { $www = __DIR__ . '/../../www/user-photo/'; $image = Image::fromFile($name['temp']); $image->save($www . $name['name']); $image->resize(80, NULL); $image->save($www . $name['nameMin']); return $name['name']; }
/** * Puts another image into this image. * @param Image * @param mixed x-coordinate in pixels or percent * @param mixed y-coordinate in pixels or percent * @param int opacity 0..100 * @return self */ public function place(Image $image, $left = 0, $top = 0, $opacity = 100) { $opacity = max(0, min(100, (int) $opacity)); if (substr($left, -1) === '%') { $left = round(($this->getWidth() - $image->getWidth()) / 100 * $left); } if (substr($top, -1) === '%') { $top = round(($this->getHeight() - $image->getHeight()) / 100 * $top); } if ($opacity === 100) { imagecopy($this->image, $image->getImageResource(), $left, $top, 0, 0, $image->getWidth(), $image->getHeight()); } elseif ($opacity != 0) { imagecopymerge($this->image, $image->getImageResource(), $left, $top, 0, 0, $image->getWidth(), $image->getHeight(), $opacity); } return $this; }