Esempio n. 1
0
 /**
  * Internal method to read image from blob (string)
  *
  * @param string  the binary data to be read
  * @return mixed an instance of the image based on library (driver), false on failure
  */
 protected function _read_image_blob($string)
 {
     switch (self::$driver) {
         case 'gd':
             return imagecreatefromstring($string);
         case 'gmagick':
         case 'imagick':
             $image = new imagick();
             $image->readImageBlob($string);
             return $image;
     }
     return FALSE;
 }
 function get_texture($uuid, $x = null, $y = null)
 {
     $image = $this->ci->curl->simple_get($this->asset_service . $uuid);
     if ($image == null) {
         return null;
     }
     $im = new imagick();
     $im->readImageBlob($image);
     $im->setImageFormat("jpeg");
     if ($x != null && $y != null) {
         $im->scaleImage(200, 200, true);
     }
     return $im;
 }
$signatureColor = $_POST['colorSignature'];
$titleFont = $_POST['selectTitleFont'];
$messageFont = $_POST['selectMessageFont'];
$signatureFont = $_POST['selectSignatureFont'];
//add hash to text color strings
$titleColor = '#' . $titleColor;
$messageColor = '#' . $messageColor;
$signatureColor = '#' . $signatureColor;
# URL's from the web
$board = "http://sometestsite.com/christmas-card-maker/images/cards/" . $selectedImage . ".png";
# read files
$board_blob = file_get_contents($board);
# create new image objects
$b = new imagick();
# read blobs
$b->readImageBlob($board_blob);
/* Draw Title */
$draw1 = new ImagickDraw();
/* Black text */
$draw1->setFillColor($titleColor);
/* Font properties */
$draw1->setFont($titleFont);
$draw1->setFontSize($titleSize);
$draw1->setFontWeight(400);
// change wordwrap depending on font size
switch ($titleSize) {
    case 20:
        $titleWordwrap = 24;
        break;
    case 22:
        $titleWordwrap = 23;