public function createThali($dishArray = array(), $is_thali, $w = 140, $h = 0)
 {
     Configure::write('debug', 2);
     ini_set("max_execution_time", -1);
     $thali1 = new Imagick("tmpl/img/thali-1.png");
     $thali2 = new Imagick("tmpl/img/thali-2.png");
     $thali3 = new Imagick("tmpl/img/thali-3.png");
     $mask_1 = new Imagick("tmpl/img/thali-mask2.png");
     $mask_2 = new Imagick("tmpl/img/thali-mask3.png");
     if (!is_array($dishArray)) {
         return false;
     }
     $mask_cnt = 0;
     foreach ($dishArray as $dish) {
         if ($mask_cnt > 1) {
             // Mask Locking (Modify if masks will be increased or decreased)
             break;
         }
         $dish = new Imagick($dish);
         $dish->scaleimage($thali1->getimagewidth(), $thali1->getimageheight());
         // Set As per bowl image
         if ($is_thali) {
             if ($mask_cnt == 1) {
                 $dish->rotateimage("#fff", 180);
             }
             $dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 2) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
             $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
             $thali1->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
             $thali1->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
             $thali2->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
             $thali2->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
             $thali3->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
             $thali3->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
         } else {
             $thali3 = $dish;
         }
         $mask_cnt++;
     }
     $url = "files/thali_images/" . $this->randomString(6);
     $url_end = "-Thali.jpg";
     $result_urls = array();
     $thali1->setimageformat("jpg");
     $thali1->setImageFileName($result_urls[] = $url . "-0" . $url_end);
     $thali1->scaleimage($w, $h);
     if ($is_thali) {
         $thali2->writeimage();
     }
     $thali1->destroy();
     $thali2->setimageformat("jpg");
     $thali2->setImageFileName($result_urls[] = $url . "-1" . $url_end);
     $thali2->scaleimage($w, $h);
     if ($is_thali) {
         $thali2->writeimage();
     }
     $thali2->destroy();
     $thali3->setimageformat("jpg");
     $thali3->setImageFileName($result_urls[] = $url . "-2" . $url_end);
     $thali3->scaleimage($w, $h);
     $thali3->writeimage();
     $thali3->destroy();
     return $result_urls;
 }
Ejemplo n.º 2
0
 public function __construct(EntityManager $entityManager)
 {
     // Tag
     $this->add(array('name' => 'tag', 'required' => true, 'filters' => array(), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Please enter a Squad Tag'))))));
     // Name
     $this->add(array('name' => 'name', 'required' => true, 'filters' => array(), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => 'Please enter a Squad Name'))))));
     // Homepage
     $this->add(array('name' => 'homepage', 'required' => false, 'filters' => array(), 'validators' => array(array('name' => 'Zend\\Validator\\Uri', 'break_chain_on_failure' => true, 'options' => array('allowRelative' => false, 'messages' => array(\Zend\Validator\Uri::INVALID => 'FRONTEND_SQUAD_URL_INVALID_FORMAT', \Zend\Validator\Uri::NOT_URI => 'FRONTEND_SQUAD_URL_INVALID_FORMAT'))))));
     // Title
     $this->add(array('name' => 'title', 'required' => false, 'filters' => array(), 'validators' => array()));
     // Email
     $this->add(array('name' => 'email', 'required' => false, 'filters' => array(), 'validators' => array(array('name' => 'Zend\\Validator\\EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\EmailAddress::INVALID => 'FRONTEND_SQUAD_EMAIL_INVALID_FORMAT'))))));
     // DeleteLogo
     $this->add(array('name' => 'deleteLogo', 'required' => false, 'filters' => array(), 'validators' => array()));
     // Upload
     $this->add(array('name' => 'logo', 'required' => false, 'filters' => array(), 'validators' => array(array('name' => 'Zend\\Validator\\File\\Extension', 'break_chain_on_failure' => true, 'options' => array('extension' => array('jpg', 'jpeg', 'gif', 'png'), 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'Es werden folgende Logos unterstützt: png,jpg,jpeg,gif'))), array('name' => 'Callback', 'options' => array('message' => array(\Zend\Validator\Callback::INVALID_VALUE => 'FRONTEND_SQUAD_LOGO_INVALID_FORMAT'), 'callback' => function ($value) {
         if ($value['error'] != 0) {
             return false;
         }
         try {
             $image = new \Imagick($value['tmp_name']);
             if ($image->getimageheight() == $image->getimagewidth() && in_array($image->getimageheight(), array(16, 32, 64, 128, 256))) {
                 return true;
             } else {
                 return false;
             }
         } catch (\Exception $e) {
             return false;
         }
         return false;
     })))));
 }
Ejemplo n.º 3
0
 /**
  * @param  $angle
  * @param bool $autoResize
  * @param string $color
  * @return Pimcore_Image_Adapter_Imagick
  */
 public function rotate($angle)
 {
     $this->resource->rotateImage(new ImagickPixel('none'), $angle);
     $this->setWidth($this->resource->getimagewidth());
     $this->setHeight($this->resource->getimageheight());
     $this->reinitializeImage();
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * 
  * @param string $dishUrl
  * @param int $w Width of the Output Image
  * @param int $h Height of Output Image
  * @return string Path of genrated Image
  */
 public function createBowl($dishUrl = null, $w = 140, $h = 0)
 {
     $bowl = new Imagick("tmpl/img/bowl.png");
     $mask = new Imagick("tmpl/img/mask.png");
     $dish = new Imagick($dishUrl);
     $dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight());
     // Set As per bowl image
     $dish->compositeimage(new Imagick("tmpl/img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
     $bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $bowl->setimageformat("jpg");
     $bowl->setImageFileName($url = "img_tmp/" . $this->randomString(10) . "-GE.jpg");
     //    $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $bowl->scaleimage($w, $h);
     $bowl->writeimage();
     $bowl->destroy();
     return $url;
 }
Ejemplo n.º 5
0
 /**
  * Resize image and save
  * @param string $sPathSrc Path to source image
  * @param string $sPathDst Path to output image
  * @param integer $iWidth Width of output image
  * @param integer $iHeight Height of output image
  * @param string $sMode Transformation mode
  * @param string $sImageForZoomPath Path for zoom thumbnail
  */
 public static function resizeImage($sPathSrc, $sPathDst, $iWidth, $iHeight, $sMode = "out", $sImageForZoomPath = null)
 {
     if (empty($sPathDst)) {
         $sPathDst = $sPathSrc;
     }
     if ($sMode == 'noresize') {
         return AM_Tools_Standard::getInstance()->copy($sPathSrc, $sPathDst);
     }
     $oSrcImage = new Imagick($sPathSrc);
     $iSrcWidth = $oSrcImage->getimagewidth();
     $iSrcHeight = $oSrcImage->getimageheight();
     //For images with horizontal proportions in vertical issue
     if ($iSrcWidth > $iSrcHeight && $iWidth < $iHeight && $sMode == 'width') {
         $iTmpHeight = $iHeight;
         $iHeight = $iWidth;
         $iWidth = $iTmpHeight;
     }
     self::_resizeImage($sPathSrc, $sPathDst, $iWidth, $iHeight, $sMode);
     if (!is_null($sImageForZoomPath)) {
         self::_resizeImage($sPathSrc, $sImageForZoomPath, $iWidth * 2, $iHeight * 2, $sMode);
     }
 }
Ejemplo n.º 6
0
function createBowl($dishUrl = null, $w = 140, $h = 0)
{
    $du = explode("/", $dishUrl);
    $du = explode(".", $du[count($du) - 1]);
    $uri = $du[count($du) - 2];
    $bowl = new Imagick("img/bowl.png");
    $mask = new Imagick("img/mask.png");
    $dish = new Imagick($dishUrl);
    $dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight());
    // Set As per bowl image
    $dish->compositeimage(new Imagick("img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
    $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
    $bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
    $bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
    $bowl->setimageformat("jpg");
    $bowl->setImageFileName($url = "gen/" . $uri . ".jpg");
    //    $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG);
    $bowl->scaleimage($w, $h);
    $bowl->writeimage();
    $bowl->destroy();
    return $url;
}
Ejemplo n.º 7
0
 /**
  * @param $fileArray
  * @param bool $create_thumb
  * @param $destination // relative to app/public/files directory, no trailing slash
  * @return bool|string
  */
 public function saveImage($fileArray, $create_thumb = false, $destination = false)
 {
     $tmp_file = $fileArray['tmp_name'];
     $name = $fileArray['name'];
     if (!$destination) {
         $dest = $this->dest;
     } else {
         $dest = $this->dest . DS . $destination;
     }
     $img = new \Imagick($tmp_file);
     $img_width = $img->getimagewidth();
     $img_height = $img->getimageheight();
     if ($this->_height == 'auto' && is_numeric($this->_width) && $img_width > $this->_width) {
         // resize only width
         $img->resizeimage($img_width, 0, \Imagick::FILTER_LANCZOS, 1);
     } elseif ($this->_width == 'auto' && is_numeric($this->_height) && $img_height > $this->_height) {
         $img->resizeimage(0, $img_height, \Imagick::FILTER_LANCZOS, 1);
     } elseif (is_numeric($this->_height) && is_numeric($this->_width)) {
         $img->resizeimage($img_width, $img_height, \Imagick::FILTER_LANCZOS, 1, 1);
     }
     #dpi
     $img->setImageUnits(\Imagick::RESOLUTION_PIXELSPERINCH);
     $img->setImageResolution($this->_dpi, $this->_dpi);
     #compression
     $img->setImageCompressionQuality($this->_compression);
     $name = substr(md5(microtime()), 0, 4) . $name;
     $name = str_replace(' ', '', $name);
     try {
         $img->writeimage($dest . DS . $name);
     } catch (\Exception $e) {
         return false;
     }
     if ($create_thumb) {
         $this->createThumb($tmp_file, $dest . DS . 'thumb_' . $name, $this->_thumb_width, $this->_thumb_height);
     }
     return $name;
 }
}
$Errore = 0;
$Answer = '';
$AthId = 0;
$image = null;
if (!empty($_REQUEST["Id"]) && ($EnId = intval($_REQUEST["Id"]))) {
    if (!empty($_REQUEST["picDelete"])) {
        safe_w_sql("DELETE FROM Photos WHERE PhEnId={$EnId}");
    }
    if (!empty($_REQUEST["picEncoded"])) {
        $picEncoded = str_replace(array('data:image/png;base64,', ' '), array('', '+'), $_REQUEST["picEncoded"]);
        $im = new Imagick();
        $im->setFormat('jpg');
        if ($im->readImageBlob(base64_decode($picEncoded))) {
            $w = $im->getImageWidth();
            $h = $im->getimageheight();
            // 			echo $w . "." . $h;exit;
            if ($w != MAX_WIDTH or $h != MAX_HEIGHT) {
                // resize image
                $im->scaleimage($w / $h < MAX_WIDTH / MAX_HEIGHT ? MAX_WIDTH : 0, $w / $h < MAX_WIDTH / MAX_HEIGHT ? 0 : MAX_HEIGHT);
                $w = $im->getImageWidth();
                $h = $im->getimageheight();
                $im->cropimage(MAX_WIDTH, MAX_HEIGHT, ($w - MAX_WIDTH) / 2, ($h - MAX_HEIGHT) / 2);
            }
            $imgtoSave = StrSafe_DB(base64_encode($im->getImageBlob()));
            safe_w_sql("insert into Photos set PhEnId={$EnId}, PhPhoto={$imgtoSave} on duplicate key update PhPhoto={$imgtoSave}");
            require_once 'Common/CheckPictures.php';
            updatePhoto($EnId);
        }
    }
    $Sql = "SELECT EnId, CONCAT(EnDivision, '-',EnClass) as Category, CONCAT(CoName, ' (' ,CoCode,')') as Country, CONCAT(UPPER(EnFirstName),' ' ,EnName) as Athlete, PhPhoto as Photo " . "FROM Entries " . "LEFT JOIN Countries ON EnCountry=CoId " . "LEFT JOIN Photos ON EnId=PhEnId " . "WHERE EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EnId=" . StrSafe_DB($_REQUEST['Id']);
Ejemplo n.º 9
0
 private function genImgRunner($rugpngs, $colors = array(), $location = "files/temp/")
 {
     if (is_file($location . "runner.png")) {
         return $location;
     }
     ini_set("max_execution_time", -1);
     $layers = array();
     $bg = null;
     foreach ($rugpngs as $rp) {
         if ($rp['type'] == "LAYER") {
             $layers[] = new Imagick($rp['path']);
         } else {
             $bg = new Imagick($rp['path']);
         }
     }
     if ($bg == NULL) {
         $bg = new Imagick();
         $bg->newImage(910, 475, new ImagickPixel('none'));
         $bg->setimageformat('png');
     }
     foreach ($layers as $layer) {
         //$layer->resizeImage(910, 475, Imagick::FILTER_LANCZOS, 1, TRUE);
         $layer->setimageformat("png");
     }
     $bg->resizeImage($layer->getimagewidth(), $layer->getimageheight(), Imagick::FILTER_LANCZOS, 1, TRUE);
     $bg->setimageformat("png");
     $cnt_a = 0;
     foreach ($layers as $layer) {
         $layer->paintopaqueimage(new ImagickPixel('#000'), $colors[$cnt_a], 900000);
         $bg->compositeimage($layer, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
         $cnt_a++;
         $layer->destroy();
     }
     $bg->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $bg = $this->getBgPresp($bg, 60);
     $rnd = new Imagick("files/templates/new/runner/angle.png");
     $bg->scaleimage(0, $rnd->getimageheight());
     $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/angle_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->setimageformat("png");
     $rnd->setImageFileName($location . "runner.png");
     $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $rnd->scaleimage(733, 0);
     $rnd->writeimage();
     $rnd->destroy();
     $rnd = new Imagick("files/templates/new/runner/flip.png");
     $bg->scaleimage(0, $rnd->getimageheight());
     $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/flip_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/flip.png"), \Imagick::COMPOSITE_DSTOVER, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->setimageformat("png");
     $rnd->setImageFileName($location . "runner1.png");
     $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $rnd->scaleimage(733, 0);
     $rnd->writeimage();
     $rnd->destroy();
     $rnd = new Imagick("files/templates/new/runner/straight.png");
     $bg->scaleimage($rnd->getimagewidth(), 0);
     $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
     $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     $rnd->compositeimage(new Imagick("files/templates/new/runner/straight_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
     $rnd->setimageformat("png");
     $rnd->setImageFileName($location . "runner2.png");
     $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $rnd->scaleimage(733, 0);
     $rnd->writeimage();
     $rnd->destroy();
     /*
      $rnd = new Imagick("files/templates/runner/runners-4.png");
      $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 200);
      $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
     
      $rnd->compositeimage(new Imagick("files/templates/runner/runners-4.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
      $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
      $rnd->compositeimage(new Imagick("files/templates/runner/runners-5.png"), \Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::CHANNEL_ALPHA);
      $rnd->setimageformat("png");
      $rnd->setImageFileName($location . "runner3.png");
      $rnd->writeimage();
      $rnd->destroy();
     */
     return $location;
 }
Ejemplo n.º 10
0
Archivo: image.php Proyecto: rair/yacs
 /**
  * Open a image and get informations
  * @param string $path to file image
  * @return array with image, width and height, or false
  */
 private static function open($path)
 {
     // get file name
     $file_name = basename($path);
     if (Image::use_magic()) {
         logger::debug('imagick available');
         $image = new Imagick($path);
         $image_information = array($image->getimagewidth(), $image->getimageheight());
     } else {
         logger::debug('imagick NOT available');
         // ensure this is a valid file
         if (!($image_information = Safe::GetImageSize($path))) {
             if ($verbose) {
                 Logger::error(sprintf(i18n::s('No image information in %s.'), $file_name));
             }
             return FALSE;
         }
         // GIF image
         if ($image_information[2] == 1 && is_callable('ImageCreateFromGIF')) {
             $image = ImageCreateFromGIF($path);
         } elseif ($image_information[2] == 2 && is_callable('ImageCreateFromJPEG')) {
             $image = ImageCreateFromJPEG($path);
         } elseif ($image_information[2] == 3 && is_callable('ImageCreateFromPNG')) {
             $image = ImageCreateFromPNG($path);
         }
         // sanity check
         if (!isset($image)) {
             if ($verbose) {
                 Logger::error(sprintf(i18n::s('No GD support, or unknown image type in %s.'), $file_name));
             }
             return FALSE;
         }
     }
     $info = array($image, $image_information);
     return $info;
 }
Ejemplo n.º 11
0
};
$frames = array_map($getFilename, range($startFrame, $endFrame, $frameSkip));
echo "There are " . count($frames) . " frames \n";
$frameDelay = $frameSkip * 100 / $frameRate;
$animation = new Imagick();
foreach ($frames as $frame) {
    echo "Adding file {$frame}\n";
    $imagickFrame = new Imagick($frame);
    //$frame->readImage($frame);
    //reduceNoiseImage
    $imagickFrame->despeckleImage();
    //$imagickFrame->reduceNoiseImage(0);
    $imagickFrame->resizeImage(0, $height, \Imagick::FILTER_LANCZOS, 2, false);
    $geo = $imagickFrame->getImageGeometry();
    $imagickFrame->cropImage($width, $height, ($geo['width'] - $width) / 2, 0);
    $imagickFrame->setImagePage($imagickFrame->getimageWidth(), $imagickFrame->getimageheight(), 0, 0);
    //$imagickFrame->gaussianBlurImage(1, 0.5);
    //$imagickFrame->orderedPosterizeImage("o8x8");
    //"o8x8,8"
    //"o8x8,10"
    //    $identifyInfo = $imagickFrame->identifyimage();
    //    var_dump($identifyInfo);
    $imagickFrame->writeImage($frame . "debug.gif");
    //if (false) {
    $paletteImage = clone $imagickFrame;
    $paletteImage->quantizeImage(256, Imagick::COLORSPACE_YIQ, 0, false, false);
    //$imagickFrame->setImageDepth(8);
    //$imagickFrame->quantizeImage(15,Imagick::COLORSPACE_TRANSPARENT,0,false,false);
    //Imagick::mapImage ( Imagick $map , bool $dither )
    $imagickFrame->remapImage($paletteImage, Imagick::DITHERMETHOD_FLOYDSTEINBERG);
    //}
Ejemplo n.º 12
0
 public function createThali($dishArray = array(), $w = 140, $h = 0)
 {
     Configure::write('debug', 2);
     ini_set("max_execution_time", -1);
     $thali = new Imagick("tmpl/img/thali.png");
     $mask_1 = new Imagick("tmpl/img/thali-mask1.png");
     $mask_2 = new Imagick("tmpl/img/thali-mask2.png");
     $mask_3 = new Imagick("tmpl/img/thali-mask3.png");
     $mask_4 = new Imagick("tmpl/img/thali-mask4.png");
     $mask_5 = new Imagick("tmpl/img/thali-mask5.png");
     if (!is_array($dishArray)) {
         return false;
     }
     $mask_cnt = 0;
     foreach ($dishArray as $dish) {
         if ($mask_cnt > 4) {
             // Mask Locking (Modify if masks will be increased or decreased)
             break;
         }
         $dish = new Imagick($dish);
         if ($mask_cnt + 1 == 5) {
             $dish = new Imagick("tmpl/dishes/rice.jpg");
             // Fixed Rice for Mask No. 1
         }
         $dish->scaleimage($thali->getimagewidth(), $thali->getimageheight());
         // Set As per bowl image
         $dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 1) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA);
         $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
         $thali->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA);
         $thali->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE);
         $mask_cnt++;
     }
     $thali->setimageformat("jpg");
     $thali->setImageFileName($url = "files/thali_images/" . $this->randomString(6) . "-Thali.jpg");
     //    $thali->setinterlacescheme(\Imagick::INTERLACE_PNG);
     $thali->scaleimage($w, $h);
     $thali->writeimage();
     $thali->destroy();
     return $url;
 }
Ejemplo n.º 13
0
 /**
  * Load actual image pixels from Imagick object
  * 
  * @param Imagick $im Image to load from
  */
 public function readImageFromImagick(Imagick $im)
 {
     /* Threshold */
     $im->setImageType(Imagick::IMGTYPE_TRUECOLOR);
     // Remove transparency (good for PDF's)
     $max = $im->getQuantumRange();
     $max = $max["quantumRangeLong"];
     $im->thresholdImage(0.5 * $max);
     /* Make a string of 1's and 0's */
     $geometry = $im->getimagegeometry();
     $this->imgHeight = $im->getimageheight();
     $this->imgWidth = $im->getimagewidth();
     $this->imgData = str_repeat("", $this->imgHeight * $this->imgWidth);
     for ($y = 0; $y < $this->imgHeight; $y++) {
         for ($x = 0; $x < $this->imgWidth; $x++) {
             /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
             $cols = $im->getImagePixelColor($x, $y);
             $cols = $cols->getcolor();
             $greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7;
             // 1 for white, 0 for black
             $this->imgData[$y * $this->imgWidth + $x] = 1 - $greyness;
             // 1 for black, 0 for white
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * @return mixed
  */
 protected function waterMark()
 {
     $oWaterMarkImg = new Imagick($this->_sWaterMarkImgPath);
     $iWaterMarkWidth = $oWaterMarkImg->getimagewidth();
     $iWaterMarkHeight = $oWaterMarkImg->getimageheight();
     $iImgWidth = $this->oImage->getimagewidth();
     $iImgHeight = $this->oImage->getimageheight();
     //图片大小小于水印大小加上30 就不打水印了
     if ($iImgWidth < $iWaterMarkWidth + 30 || $iImgHeight < $iWaterMarkHeight + 30) {
         return true;
     }
     switch ($this->_sWaterMarkPosition) {
         //左下
         case "bottom-left":
             $iDesX = 30;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
             //右下
         //右下
         case "bottom-right":
             $iDesX = $iImgWidth - $iWaterMarkWidth - 30;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
             //中下
         //中下
         case "bottom-middle":
             $iDesX = $iImgHeight / 2 - 15;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
             //左上
         //左上
         case "top-left":
             $iDesX = 30;
             $iDesY = 30;
             break;
             break;
             //中上
         //中上
         case "top-middle":
             $iDesX = $iImgHeight / 2 - 15;
             $iDesY = 30;
             break;
             break;
             //右上
         //右上
         case "top-right":
             $iDesX = $iImgWidth - $iWaterMarkWidth - 30;
             $iDesY = 30;
             break;
             break;
             //默认右下
         //默认右下
         default:
             $iDesX = $iImgWidth - $iWaterMarkWidth - 30;
             $iDesY = $iImgHeight - $iWaterMarkHeight - 30;
             break;
     }
     if ($this->oImage->getimageformat() == 'GIF') {
         $aFrame = $this->oImage->coalesceImages();
         $draw = new ImagickDraw();
         $draw->composite($oWaterMarkImg->getImageCompose(), $iDesX, $iDesY, $iWaterMarkWidth, $iWaterMarkHeight, $oWaterMarkImg);
         foreach ($aFrame as $frame) {
             $frame->drawImage($draw);
         }
         $aFrame->optimizeimagelayers();
         $this->oImage = $aFrame;
     } else {
         $draw = new ImagickDraw();
         $draw->composite($oWaterMarkImg->getImageCompose(), $iDesX, $iDesY, $iWaterMarkWidth, $iWaterMarkHeight, $oWaterMarkImg);
         $this->oImage->drawImage($draw);
     }
 }
Ejemplo n.º 15
0
 public function RenderImage($strPath = null)
 {
     $objImage = new Imagick();
     $objImage->ReadImage($this->strImagePath);
     // Get Image Size
     $intSourceWidth = $objImage->getimagewidth();
     $intSourceHeight = $objImage->getimageheight();
     // We need to calculate the following values:
     $intDestinationWidth = null;
     $intDestinationHeight = null;
     $intCanvasWidth = null;
     $intCanvasHeight = null;
     /////////////////////////////////////////////
     // Calculate Dimensions: Based ONLY on WIDTH
     /////////////////////////////////////////////
     if ($this->strWidth && !$this->strHeight) {
         // DIMENSIONS THE SAME -- Flow Through
         if ($this->strWidth == $intSourceWidth) {
             $intDestinationWidth = $intSourceWidth;
             $intDestinationHeight = $intSourceHeight;
             $intCanvasWidth = $intSourceWidth;
             $intCanvasHeight = $intSourceHeight;
             // DESTINATION LARGER than source
         } else {
             if ($this->strWidth > $intSourceWidth) {
                 // Do NOT Scale "Up"
                 if (!$this->blnScaleImageUp) {
                     // Scale Canvas -- Flow Through
                     if ($this->blnScaleCanvasDown) {
                         $intDestinationWidth = $intSourceWidth;
                         $intDestinationHeight = $intSourceHeight;
                         $intCanvasWidth = $intSourceWidth;
                         $intCanvasHeight = $intSourceHeight;
                         // Do NOT Scale Canvas -- Canvas width matches requested width. Destionation matches Source dimensions.
                     } else {
                         $intDestinationWidth = $intSourceWidth;
                         $intDestinationHeight = $intSourceHeight;
                         $intCanvasWidth = $this->strWidth;
                         $intCanvasHeight = $intSourceHeight;
                     }
                     // SCALE UP source image -- Canvas and Destination widths both match requested width.  Canvas and Destination height both need to scale up.
                 } else {
                     $intDestinationWidth = $this->strWidth;
                     $intDestinationHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                     $intCanvasWidth = $this->strWidth;
                     $intCanvasHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                 }
                 // DESTINATION SMALLER than source -- Scale Down Source Image.  Canvas is size of image
             } else {
                 $intDestinationWidth = $this->strWidth;
                 $intDestinationHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                 $intCanvasWidth = $intDestinationWidth;
                 $intCanvasHeight = $intDestinationHeight;
             }
         }
         /////////////////////////////////////////////
         // Calculate Dimensions: Based ONLY on HEIGHT
         /////////////////////////////////////////////
     } else {
         if ($this->strHeight && !$this->strWidth) {
             // DIMENSIONS THE SAME -- Flow Through
             if ($this->strHeight == $intSourceHeight) {
                 $intDestinationWidth = $intSourceWidth;
                 $intDestinationHeight = $intSourceHeight;
                 $intCanvasWidth = $intSourceWidth;
                 $intCanvasHeight = $intSourceHeight;
                 // DESTINATION LARGER than source
             } else {
                 if ($this->strHeight > $intSourceHeight) {
                     // Do NOT Scale "Up"
                     if (!$this->blnScaleImageUp) {
                         // Scale Canvas -- Flow Through
                         if ($this->blnScaleCanvasDown) {
                             $intDestinationWidth = $intSourceWidth;
                             $intDestinationHeight = $intSourceHeight;
                             $intCanvasWidth = $intSourceWidth;
                             $intCanvasHeight = $intSourceHeight;
                             // Do NOT Scale Canvas -- Canvas height matches requested height. Destionation matches Source dimensions.
                         } else {
                             $intDestinationWidth = $intSourceWidth;
                             $intDestinationHeight = $intSourceHeight;
                             $intCanvasWidth = $intSourceWidth;
                             $intCanvasHeight = $this->strHeight;
                         }
                         // SCALE UP source image -- Canvas and Destination heights both match requested height.  Canvas and Destination widths both need to scale up.
                     } else {
                         $intDestinationWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                         $intDestinationHeight = $this->strHeight;
                         $intCanvasWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                         $intCanvasHeight = $this->strHeight;
                     }
                     // DESTINATION SMALLER than source -- Scale Down Source Image.  Canvas is size of image
                 } else {
                     $intDestinationWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                     $intDestinationHeight = $this->strHeight;
                     $intCanvasWidth = $intDestinationWidth;
                     $intCanvasHeight = $intDestinationHeight;
                 }
             }
             /////////////////////////////////////////////
             // Calculate Dimensions based on BOTH DIMENSIONS
             /////////////////////////////////////////////
         } else {
             // DIMENSIONS THE SAME -- Flow Through
             if ($this->strHeight == $intSourceHeight && $this->strWidth == $intSourceWidth) {
                 $intDestinationWidth = $intSourceWidth;
                 $intDestinationHeight = $intSourceHeight;
                 $intCanvasWidth = $intSourceWidth;
                 $intCanvasHeight = $intSourceHeight;
                 // DESTINATION LARGER than source
             } else {
                 if ($this->strHeight >= $intSourceHeight && $this->strWidth >= $intSourceWidth) {
                     // Do NOT Scale "Up"
                     if (!$this->blnScaleImageUp) {
                         // Scale Canvas - Flow Through
                         if ($this->blnScaleCanvasDown) {
                             $intDestinationWidth = $intSourceWidth;
                             $intDestinationHeight = $intSourceHeight;
                             $intCanvasWidth = $intSourceWidth;
                             $intCanvasHeight = $intSourceHeight;
                             // Do NOT Scale Canvas -- Canvas Dimensions match Requested Dimensions.  Destination dimensions match Source Dimensions
                         } else {
                             $intDestinationWidth = $intSourceWidth;
                             $intDestinationHeight = $intSourceHeight;
                             $intCanvasWidth = $this->strWidth;
                             $intCanvasHeight = $this->strHeight;
                         }
                     }
                 }
             }
             // If no Dest Width is defined, then we haven't done any calculations yet.  This means that we are either
             // scaling up OR down the source image.  Scale Destination Dimensions to the maximum possible, given the requested width/height
             if (!$intDestinationWidth) {
                 // Calculate Image Proportions for Source and Destination
                 $fltSourceProportions = $intSourceWidth / $intSourceHeight;
                 $fltDestProportions = $this->strWidth / $this->strHeight;
                 // Destination is WIDER than Source -- therefore HEIGHT defined by Requested Height, and Width is calculated
                 if ($fltDestProportions > $fltSourceProportions) {
                     $intDestinationWidth = $intSourceWidth * $this->strHeight / $intSourceHeight;
                     $intDestinationHeight = $this->strHeight;
                     // Destination is TALLER than Source -- therefore WIDTH defined by Requested Width, and Height is calculated
                 } else {
                     if ($fltDestProportions < $fltSourceProportions) {
                         $intDestinationWidth = $this->strWidth;
                         $intDestinationHeight = $intSourceHeight * $this->strWidth / $intSourceWidth;
                         // Destination Proportions MATCH Source Proportions -- Width/Height defined by Requested Width/Height
                     } else {
                         $intDestinationWidth = $this->strWidth;
                         $intDestinationHeight = $this->strHeight;
                         $intCanvasWidth = $intDestinationWidth;
                         $intCanvasHeight = $intDestinationHeight;
                     }
                 }
             }
             // If No Canvas Dimensions Defined, Calculate this now
             if (!$intCanvasWidth) {
                 if ($this->blnScaleCanvasDown) {
                     $intCanvasWidth = $intDestinationWidth;
                     $intCanvasHeight = $intDestinationHeight;
                 } else {
                     $intCanvasWidth = $this->strWidth;
                     $intCanvasHeight = $this->strHeight;
                 }
             }
         }
     }
     $objImage->resizeimage($intDestinationWidth, $intDestinationHeight, imagick::FILTER_QUADRATIC, 0.5);
     // Calculate X and Y position
     $intX = round(($intCanvasWidth - $intDestinationWidth) / 2.0);
     $intY = round(($intCanvasHeight - $intDestinationHeight) / 2.0);
     // Create Destination Image
     $objFinalImage = new Imagick();
     $objFinalImage->NewImage($intCanvasWidth, $intCanvasHeight, new ImagickPixel('#' . $this->strBackColor));
     $objFinalImage->CompositeImage($objImage, imagick::COMPOSITE_DEFAULT, $intX, $intY);
     $this->RenderImageMagickHelper($objFinalImage, $strPath);
 }
Ejemplo n.º 16
0
 /**
  * Primary processing routine for the source
  */
 private function processBook()
 {
     // Get Media manager and preset page parameters
     $mediaManager = new MediaManager($this->bookId);
     $pageCount = count($this->sourceFiles) + count($this->sourceAssets);
     $pageNumber = 1;
     // Prepare the progress
     $this->progress->startProgress($pageCount * 2);
     $this->updatePageCount(0);
     $bookSizeFound = false;
     // Loop through source files
     foreach ($this->sourceFiles as $source) {
         CakeLog::debug('[ImageProcessor::processBook] processing source file ' . $source);
         // Get book size
         if (!$bookSizeFound) {
             $bookWidth = 0;
             $bookHeight = 0;
             $this->getBookSizeImage($source, $bookWidth, $bookHeight);
             CakeLog::debug('[ImageProcessor::processBook] Book dimensions set to ' . $bookWidth . ' x ' . $bookHeight);
             $this->updateBookSize($bookWidth, $bookHeight);
             $bookSizeFound = true;
         }
         // Convert to png as needed
         if (MediaManager::isConvertableImage($source)) {
             CakeLog::debug('[ImageProcessor::processBook] Converting ' . $source . ' to png');
             $mediaManager->imageConvertToPng($source, $source);
         }
         // Resize image to max dimension.
         $image = new Imagick($source);
         $width = $image->getimagewidth();
         $height = $image->getimageheight();
         // Get new width and height
         list($newWidth, $newHeight) = $this->getResizedDimensionsForMaxPixels($width, $height);
         if ($newHeight != $height || $newWidth != $width) {
             CakeLog::debug('[ImageProcessor::processBook] ' . $source . ' resized for max pixel limits to ' . $newWidth . 'x' . $newHeight);
             // Resize the original image
             $img = new Imagick($source);
             $img->resizeimage($newWidth, $newHeight, Imagick::FILTER_LANCZOS, 1, false);
             $img->writeimage();
         }
         $this->addImageAssetToBook($source, 'images/backgrounds/');
         $this->savePageHTML('', $pageNumber, null, '../images/backgrounds/' . basename($source));
         @unlink($source);
         $this->savePageCSS('', $pageNumber);
         // Count page
         $pageNumber++;
         // Update the progress in database every 10th page.
         $this->progress->incrementStep();
     }
     //handle any non-source assets included with the book source files
     $this->importSourceAssets();
     $this->setCoverImage();
     // Save default book CSS
     $this->saveBookCSS('');
     // Generate thumbnails
     $this->generateThumbnails(1, $pageCount);
     $this->updatePageCount($pageCount);
     CakeLog::debug('[ImageProcessor::processBook] Book Processing Complete');
 }
Ejemplo n.º 17
0
 /**
  * 
  * 获取图片信息
  * @param unknown_type $img
  */
 public function getImageInfo($img)
 {
     $image = new Imagick($img);
     $handle = $image->readimage($img);
     if (!$handle) {
         return false;
     }
     $width = $image->getimagewidth();
     $height = $image->getimageheight();
     $mime = $image->getimagemimetype();
     $type = $image->getimageformat();
     $size = $image->getimagesize();
     $resolution = $image->getimageresolution();
     $unit = $image->getimageunits();
     $info = array('width' => $width, 'height' => $height, 'mime' => $mime, 'type' => $type, 'size' => $size, 'resolution' => $resolution, 'unit' => $unit);
     $image->destroy();
     return $info;
 }
Ejemplo n.º 18
0
 public function add_full_watermark($path, $x = 0, $y = 0)
 {
     $watermark = new Imagick($path);
     $draw = new ImagickDraw();
     $image = $this->image;
     $image_w = $image->getImageWidth();
     $image_h = $image->getimageheight();
     $water_w = $watermark->getImageWidth();
     $water_h = $watermark->getimageheight();
     $a = floor($image_w / $water_w);
     $b = floor($image_h / $water_h);
     //$offset_x = ($image_w>$water_w)?floor($image_w%$water_w/2):0;
     //$offset_y = ($image_h>$water_h)?floor($image_h%$water_h/2):0;
     $offset_x = $offset_y = 0;
     for ($i = 0; $i <= $a; $i++) {
         for ($j = 0; $j <= $b; $j++) {
             $draw->composite($watermark->getImageCompose(), $i * $water_w + $offset_x, $j * $water_h + $offset_y, $water_w, $water_h, $watermark);
         }
     }
     if ($this->type == 'gif') {
         $image = $this->image;
         $canvas = new Imagick();
         $images = $image->coalesceImages();
         foreach ($image as $frame) {
             $img = new Imagick();
             $img->readImageBlob($frame);
             $img->drawImage($draw);
             $canvas->addImage($img);
             $canvas->setImageDelay($img->getImageDelay());
         }
         $image->destroy();
         $this->image = $canvas;
     } else {
         $this->image->drawImage($draw);
     }
 }
Ejemplo n.º 19
0
 /**
  * @param $field
  * @param $max_width
  * @param $max_height
  * @return bool
  */
 public function resize($field, $max_width, $max_height)
 {
     if (!class_exists('\\Imagick') || !isset($this->last_uploads[$field][2])) {
         return true;
     }
     $img_path = $this->last_uploads[$field][2];
     $img = new \Imagick($img_path);
     $w = $img->getimagewidth();
     $h = $img->getimageheight();
     $nw = $w;
     $nh = $h;
     if ($w > $max_width) {
         $nw = $max_width;
     }
     if ($h > $max_height) {
         $nh = $max_height;
     }
     if ($nw != $w || $nh != $h) {
         $img->resizeImage($nw, $nh, \Imagick::FILTER_LANCZOS, 1);
     } else {
         return true;
     }
     return $img->writeimage($img_path) && $img->destroy();
 }
Ejemplo n.º 20
0
 /**
  * 添加图片水印 
  * 有个别水印图片打不漂亮;貌似对jpg图片打出来还不错
  * @see Lib_Image_Abstract::watermarkImage()
  * @param string $watermarkPath 水印图片(最好是透明背景的png图片)
  * @param string $place 水印位置;具体对应参数如下(可参见常量)
  *         northwest            northeast 
  *                     center
  *         southwest            southeast
  * @param integer $x 水印位置 ; x(水平坐标轴)轴偏移量
  * @param integer $y 水印位置 ; y(垂直坐标轴)轴偏移量
  * @param integer $alpha 水印透明度。取值0(全透明)-100(完全不透明) ;默认52:半透明
  * @param integer $angle 水印图片旋转角度  TODO
  * @return boolean
  */
 public function watermarkImage($watermarkPath, $place = 'southeast', $x = 18, $y = 18, $alpha = 52, $angle = 0)
 {
     if (!is_file($watermarkPath)) {
         $this->_error = '水印文件不存在';
         $this->_im = null;
         return false;
     }
     if (!$this->_isExistIm()) {
         return false;
     }
     try {
         $watermark = new Imagick();
         $watermark->readImage($watermarkPath);
         $alpha = $alpha / 100;
         $watermark->setImageOpacity($alpha);
         // 设置透明度,不知道为什么这里如果设了透明度,有些png水印打出来的图片就不漂亮了
         // 在ubuntu 64 位上还是一样
         $watermarkW = $watermark->getimagewidth();
         $watermarkH = $watermark->getimageheight();
         switch ($place) {
             case self::PLACE_NORTHWEST:
                 break;
             case self::PLACE_NORTHEAST:
                 $x = $this->_sourceWidth - ($watermarkW + $x);
                 break;
             case self::PLACE_CENTER:
                 $x = intval(($this->_sourceWidth - $watermarkW) / 2);
                 $y = intval(($this->_sourceHeight - $watermarkH) / 2);
                 break;
             case self::PLACE_SOUTHWEST:
                 $y = $this->_sourceHeight - ($watermarkH + $y);
                 break;
             case self::PLACE_SOUTHEAST:
                 $x = $this->_sourceWidth - ($watermarkW + $x);
                 $y = $this->_sourceHeight - ($watermarkH + $y);
                 break;
             default:
                 $x = $this->_sourceWidth - ($watermarkW + $x);
                 $y = $this->_sourceHeight - ($watermarkH + $y);
                 break;
         }
         $compose = $watermark->getImageCompose();
         // 方法一
         //return $this->_im->compositeimage($watermark, $compose, $x, $y);
         // 方法二
         $draw = new ImagickDraw();
         $draw->composite($compose, $x, $y, $watermarkW, $watermarkH, $watermark);
         if ($this->_sourceType == self::TYPE_GIF) {
             $this->_im = $this->_im->coalesceImages();
             $flag = true;
             foreach ($this->_im as $frame) {
                 $boolean = $frame->drawImage($draw);
                 if (!$boolean) {
                     $flag = false;
                     $this->_im = null;
                     $this->_error = '添加水印出错!';
                     break;
                 }
             }
             return $flag;
         }
         return $this->_im->drawImage($draw);
     } catch (Exception $e) {
         $this->_error = '处理水印图片出错';
         $this->_im = null;
         return false;
     }
 }
Ejemplo n.º 21
0
 public function build($target_file = false)
 {
     $this->_debug('Beginning build!');
     $this->clean();
     // make sure we have source images
     $this->_debug('...ensuring source images exist...');
     if (count($this->image_bank) == 0) {
         $this->_gatherSourceImages();
     } else {
         $this->_debug('...complete!', false);
     }
     // make sure we have the target file set
     $this->_debug('...ensuring target is defined...');
     if (!$target_file) {
         $this->_debug('...choosing target image at random...', false);
         $target_file = $this->image_bank[rand(0, count($this->image_bank) - 1)]['orig_file'];
         $this->_debug('...' . $target_file . ' chosen!', false);
     } else {
         $this->_debug('...complete!', false);
     }
     $this->_debug('...ensuring target file availability...');
     if (!file_exists(getcwd() . $target_file)) {
         show_error('Target file is not available');
     }
     $this->_debug('...complete!', false);
     // determine map size
     $this->_debug('...determining map sizing...');
     $size = getimagesize(getcwd() . $target_file);
     $w = $this->config['num_columns'];
     $h = floor($size[1] * ($w / $size[0]));
     $this->_debug('...complete!', false);
     // create map image
     $this->_debug('...creating map image from ' . $target_file . '...');
     $map_img = new Imagick(getcwd() . $target_file);
     $map_img->resizeimage($w, $h, $this->resize_filter, 1);
     $this->_debug('...complete!', false);
     // build map
     $this->_debug('...building pixel map...');
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             $p = $map_img->getimagepixelcolor($x, $y);
             $map[$x][$y] = $p->getcolor();
         }
     }
     $map_img = null;
     $this->_debug('...complete!', false);
     $this->_debug('...creating Prosaic canvas...');
     $output = new Imagick();
     $output->newimage($w * $this->config['tile_size'], $h * $this->config['tile_size'], 'white');
     $this->_debug('...complete!', false);
     $this->_debug('...gathering Prosaic setup information...');
     $images = array();
     $positions = array();
     $rgb = array();
     for ($y = 0; $y < count($map[0]); $y++) {
         for ($x = 0; $x < count($map); $x++) {
             $images[] = $this->image_bank[$this->_getImageClosestToPixel($map[$x][$y])]['orig_file'];
             $positions[] = [$x * $this->config['tile_size'], $y * $this->config['tile_size']];
             $rgb[] = $map[$x][$y];
         }
     }
     $this->_debug('...complete!', false);
     $this->_debug(var_export($this->used_images, true));
     $this->_debug('...adding images to Prosaic...');
     $count = 0;
     $opacity = new ImagickPixel('rgba(128, 128, 128, 1)');
     foreach ($images as $image) {
         $next = $tint = null;
         $next = new Imagick(getcwd() . $image);
         $tint_string = 'rgb(' . $rgb[$count]['r'] . ', ' . $rgb[$count]['g'] . ', ' . $rgb[$count]['b'] . ')';
         $this->_debug('...tinting image with ' . $tint_string . '...');
         $tint = new ImagickPixel($tint_string);
         if (!$next->tintimage($tint, $opacity)) {
             $this->_debug('FAILED!...', false);
         }
         $this->_debug('and again', false);
         if (!$next->tintimage($tint, $opacity)) {
             $this->_debug('FAILED!...', false);
         }
         $this->_debug('...resizing image ' . $count . '...', false);
         $next->resizeimage($this->config['tile_size'], $this->config['tile_size'], $this->resize_filter, 1);
         $this->_debug('...setting page...', false);
         $next->setimagepage($next->getimagewidth(), $next->getimageheight(), $positions[$count][0], $positions[$count][1]);
         $this->_debug('...adding image...', false);
         $output->addimage($next);
         $this->_debug('...complete!', false);
         $count++;
     }
     $this->_debug('...images added!');
     $this->_debug('...buildling Prosaic...');
     $result = $output->mergeimagelayers(Imagick::LAYERMETHOD_MOSAIC);
     $output = null;
     $result->setimageformat($this->config['target_format']);
     $this->_debug('...complete!', false);
     $filename = $this->config['source_image_folder'] . $this->config['target_filename'] . '.' . $this->config['target_format'];
     $this->_debug('...saving Prosaic as ' . $filename . '...');
     if (!$result->writeimage($filename)) {
         show_error('Could not create Prosaic file');
     }
     $this->_debug('...complete!', false);
     $this->_debug('Build complete!');
 }