fromResource() 공개 정적인 메소드

Creates an instance of image from resource.
public static fromResource ( $resource )
예제 #1
0
<?php

$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data = base64_decode($data);
require_once '../Image.php';
use Gregwar\Image\Image;
$gd = imagecreatefromstring($data);
Image::fromResource($gd)->save('out.jpg');
예제 #2
0
 /**
  * Upsert an image resource with a given storage key
  *
  * @param string $targetName storage key
  * @param resource $imgRsrc image resource
  */
 public function upsertResource($targetName, $imgRsrc)
 {
     $path = $this->getStoragePath($targetName);
     Image::fromResource($imgRsrc)->setCacheDir($this->cacheDir)->cropResize($this->sizeConfig[self::MAX_RES], $this->sizeConfig[self::MAX_RES])->save($path);
 }