public function save($conn = null)
 {
     $return = parent::save($conn);
     if ($this->getObject()->getPath() != '') {
         $uploadDir = sfConfig::get('sf_upload_dir') . '/photo/';
         $image = explode('.', $this->getObject()->getPath());
         $img = new sfImage($uploadDir . $image[0] . '.' . $image[1], swImageTransform::mime_content_type($uploadDir . $image[0] . '.' . $image[1]));
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(780, 518);
         } else {
             $img->resize(344, 518);
         }
         $img->setQuality(95);
         $img->overlay(new sfImage(sfConfig::get('sf_web_dir') . '/images/marcadagua.png', 'image/png'), 'bottom-right');
         $img->saveAs($uploadDir . $this->getObject()->getSlug() . '.' . $image[1]);
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(130, 86);
         } else {
             $img->resize(130, 196);
             $img->crop(0, 55, 130, 86);
         }
         $img->saveAs($uploadDir . 'thumb_' . $this->getObject()->getSlug() . '.' . $image[1]);
         unlink($uploadDir . $image[0] . '.' . $image[1]);
         $this->getObject()->setPath($this->getObject()->getSlug() . '.' . $image[1]);
         $this->getObject()->save();
     }
     return $return;
 }
 /**
  * Apply the opacity transformation to the sfImage object
  * 
  * @param sfImage
  * 
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $new_img = $image->getAdapter()->getTransparentImage($image->getWidth(), $image->getHeight());
     imagealphablending($new_img, false);
     imagesavealpha($new_img, true);
     $opacity = (int) round(127 - 127 / 100 * $this->getOpacity());
     // imagesavealpha($new_img, true);
     $width = $image->getWidth();
     $height = $image->getHeight();
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $rgb = imagecolorat($image->getAdapter()->getHolder(), $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $alpha = ($rgb & 0x7f000000) >> 24;
             $new_opacity = $alpha + (127 - $alpha) / 100 * $this->getOpacity();
             $colors[$alpha] = $new_opacity;
             $color = imagecolorallocatealpha($new_img, $r, $g, $b, $new_opacity);
             imagesetpixel($new_img, $x, $y, $color);
         }
     }
     $image->getAdapter()->setHolder($new_img);
     return $image;
 }
Beispiel #3
0
function image_cache_tag($route, $format, $path, $image, $alt = null)
{
    $_formats = sfConfig::get('imagecache_formats');
    $_format = $_formats[$format];
    if (!isset($_format)) {
        throw new RuntimeException('Format not found');
    }
    $real_file_path = sfConfig::get('sf_upload_dir') . '/' . $path . '/' . $image;
    if (file_exists($real_file_path)) {
        $cache_file_path = sfConfig::get('sf_upload_dir') . '/cache/' . $format . '/' . $path . '/' . $image;
        $is_cached_file = file_exists($cache_file_path);
        $options = array('path' => $format . '/' . $path . '/' . $image);
        $url = urldecode(url_for($route, $options));
        if ($is_cached_file) {
            $cached_image = new sfImage($cache_file_path);
            $width = $cached_image->getWidth();
            $height = $cached_image->getHeight();
            return image_tag($url, array('size' => $width . 'x' . $height, 'alt' => $alt));
        } else {
            return image_tag($url, array('alt' => $alt));
        }
    } else {
        return '';
    }
}
Beispiel #4
0
 public function transform(sfImage $img)
 {
     $this->directory = dirname($img->getFilename());
     $arr = array_reverse(explode("/", $img->getFilename()));
     $this->fileName = $arr[0];
     $arr2 = explode(".", $this->fileName);
     if (count($arr2) == 1) {
         $this->fileName .= '.png';
     }
     $destDir = '/tmp';
     $ccFile = $destDir . DIRECTORY_SEPARATOR . 'cc_' . $this->fileName;
     $bwFile = $destDir . DIRECTORY_SEPARATOR . 'bw_' . $this->fileName;
     $ccSmallFile = $destDir . DIRECTORY_SEPARATOR . 'cc_s_' . $this->fileName;
     $bwSmallFile = $destDir . DIRECTORY_SEPARATOR . 'bw_s_' . $this->fileName;
     if (!file_exists($destDir)) {
         mkdir($destDir);
     }
     if ($img->getWidth() > IMG_MAX_WIDTH || $img->getHeight() > IMG_MAX_HEIGHT) {
         if ($img->getWidth() > $img->getHeight() * IMG_RATIO) {
             $img->resize(IMG_MAX_WIDTH, null);
         } else {
             $img->resize(null, IMG_MAX_HEIGHT);
         }
     }
     $img->saveAs($ccFile);
     $img->greyscale()->saveAs($bwFile);
     $smallImg = new sfImage($ccFile);
     if ($smallImg->getWidth() > IMG_SMALL_WIDTH || $smallImg->getHeight() > IMG_SMALL_WIDTH) {
         if ($smallImg->getWidth() > $img->getHeight() * IMG_RATIO) {
             $smallImg->resize(null, IMG_MAX_HEIGHT);
         } else {
             $smallImg->resize(IMG_MAX_WIDTH, null);
         }
     }
     if ($smallImg->getWidth() > IMG_SMALL_WIDTH || $smallImg->getHeight() > IMG_SMALL_HEIGHT) {
         if ($smallImg->getWidth() > $smallImg->getHeight() * IMG_RATIO) {
             $smallImg->resize(null, IMG_SMALL_HEIGHT);
         } else {
             $smallImg->resize(IMG_SMALL_WIDTH, null);
         }
     }
     $x1 = ($smallImg->getWidth() - IMG_SMALL_WIDTH) / 2;
     $y1 = ($smallImg->getHeight() - IMG_SMALL_HEIGHT) / 3;
     $smallImg->crop($x1, $y1, IMG_SMALL_WIDTH, IMG_SMALL_HEIGHT)->saveAs($ccSmallFile);
     $smallImg->greyscale()->saveAs($bwSmallFile);
 }
Beispiel #5
0
 public function save($conn = null)
 {
     $return = parent::save($conn);
     if ($this->getObject()->getPicture() != '') {
         $uploadDir = sfConfig::get('sf_upload_dir') . '/news/';
         $image = $this->getObject()->getPicture();
         $img = new sfImage($uploadDir . $image, swImageTransform::mime_content_type($uploadDir . $image));
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(480, null);
         } else {
             $img->resize(null, 360);
         }
         $img->setQuality(95);
         $img->save();
         $img->resize(180, 128)->saveAs($uploadDir . 'thumb_' . $image);
     }
     return $return;
 }
Beispiel #6
0
 public function save($conn = null)
 {
     $return = parent::save($conn);
     if (!$this->isNew() and count($this->embeddedForms) != 0) {
         $uploadDir = sfConfig::get('sf_upload_dir') . '/gallery/';
         $image = $this->embeddedForms['photo']->getObject()->getPath();
         $img = new sfImage($uploadDir . $image, swImageTransform::mime_content_type($uploadDir . $image));
         if ($img->getWidth() > $img->getHeight()) {
             $img->resize(600, null);
         } else {
             $img->resize(null, 480);
         }
         $img->setQuality(95);
         $img->overlay(new sfImage(sfConfig::get('sf_web_dir') . '/images/marcadagua.png', 'image/png'), 'bottom-right');
         $img->save();
         $img->resize(null, 80)->saveAs($uploadDir . 'thumb_' . $image);
     }
     return $return;
 }
Beispiel #7
0
/**
 * Cette funciton permet de récupérer les dimensions de l'image d'origine.
 * @param <string> $image_name : le nom de l’image donc généralement le $object->getImage(), pas de répertoire
 * @param <string> $folder : le nom du répertoire dans "uploads" où est stocké l’image 
 * @return <image_path>
 */
function getSize($image_name, $folder)
{
    $source_dir = 'uploads/' . $folder . '/';
    $source = $source_dir . $image_name;
    $exist = sfConfig::get('sf_web_dir') . '/' . $source;
    $img = new sfImage($source);
    $size['width'] = $img->getWidth();
    $size['height'] = $img->getHeight();
    return $size;
}
Beispiel #8
0
/**
 * Cette funciton utilise la pr?c?dente afin d'afficher directement l'image avec les balises et les options.
 * @param <string> $image_name : le nom de l'image donc g?n?ralement le $object->getImage(), pas de r?pertoire
 * @param <string> $folder : le nom du r?pertoire dans uploads o? est stock? l'image : uploads/object/source => $folder = object
 * @param <array> $options : les parametres ? passer ? l'image: width, height, alt, title, class, id...
 * @param <string> $resize : l'op?ration sur le thumb: "scale" pour garder les proportions, "center" pour tronquer l'image
 * @param <string> $default : l'image par d?faut si image_name n'existe pas
 * @return <image_path>
 */
function showThumb($image_name, $folder, $options = array(), $resize = 'scale', $default = 'default.jpg')
{
    if (empty($options['alt'])) {
        $options['alt'] = 'image ' . $image_name;
    }
    $image_path = doThumb($image_name, $folder, $options, $resize, $default);
    $img = new sfImage(sfConfig::get('sf_web_dir') . $image_path);
    //r�cupere les vraies dimensions de l'image du thumb et on �crase dans les options.
    $options['width'] = $img->getWidth();
    $options['height'] = $img->getHeight();
    return image_tag($image_path, $options);
}
 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     $resource_w = $image->getWidth();
     $resource_h = $image->getHeight();
     $scale_w = $this->getWidth() / $resource_w;
     $scale_h = $this->getHeight() / $resource_h;
     switch ($this->getMethod()) {
         case 'deflate':
         case 'inflate':
             return $image->resize($this->getWidth(), $this->getHeight());
         case 'left':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop(0, (int) round(($image->getHeight() - $this->getHeight()) / 2), $this->getWidth(), $this->getHeight());
         case 'right':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($image->getWidth() - $this->getWidth(), (int) round(($image->getHeight() - $this->getHeight()) / 2), $this->getWidth(), $this->getHeight());
         case 'top':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop((int) round(($image->getWidth() - $this->getWidth()) / 2), 0, $this->getWidth(), $this->getHeight());
         case 'bottom':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop((int) round(($image->getWidth() - $this->getWidth()) / 2), $image->getHeight() - $this->getHeight(), $this->getWidth(), $this->getHeight());
         case 'center':
             $image->scale(max($scale_w, $scale_h));
             $left = (int) round(($image->getWidth() - $this->getWidth()) / 2);
             $top = (int) round(($image->getHeight() - $this->getHeight()) / 2);
             return $image->crop($left, $top, $this->getWidth(), $this->getHeight());
         case 'scale':
             return $image->scale(min($scale_w, $scale_h));
         case 'fit':
         default:
             $img = clone $image;
             $image->create($this->getWidth(), $this->getHeight());
             // Set a background color if specified
             if (!is_null($this->getBackground()) && $this->getBackground() != '') {
                 $image->fill(0, 0, $this->getBackground());
             }
             $img->scale(min($this->getWidth() / $img->getWidth(), $this->getHeight() / $img->getHeight()));
             $image->overlay($img, 'center');
             return $image;
     }
 }
 /**
  * Apply the transformation to the image and returns the resized image
  */
 protected function transform(sfImage $image)
 {
     list($target_w, $target_h) = $this->computeTargetSize($image->getWidth(), $image->getHeight());
     return $image->resizeSimple($target_w, $target_h);
 }
 protected function updateRemoteImage($image, Swift_Message $message, $templateName)
 {
     $fileName = dmOs::join(sfConfig::get('sf_web_dir'), 'cache/mail_templates', md5($image->src . $image->width . $image->height) . pathinfo($image->src, PATHINFO_EXTENSION));
     if (!file_exists($fileName)) {
         $imageData = file_get_contents($image->src);
         if (!$imageData) {
             $this->logError($templateName, 'remote', 'image', $image->src);
             $image->src = '';
             return $image;
         } else {
             $sfImage = new sfImage();
             $sfImage->loadString($imageData);
             $width = $sfImage->getWidth();
             $height = $sfImage->getHeight();
             if (isset($image->width) && strpos($image->width, '%') === false) {
                 $width = $image->width;
             }
             if (isset($image->height) && strpos($image->height, '%') === false) {
                 $width = $image->height;
             }
             $sfImage->setQuality(dmConfig::get('image_resize_quality'));
             $sfImage->thumbnail($width, $height, dmConfig::get('image_resize_method'), null);
             $fileSystem = $this->serviceContainer->getService('filesystem');
             if (!file_exists(dirname($fileName))) {
                 $fileSystem->mkdir(dirname($fileName));
             }
             $sfImage->saveAs($fileName);
             chmod($fileName, 0777);
         }
     }
     if (dmConfig::get('mail_template_embed_remote_images_as_attachments', true)) {
         $image->src = $message->embed(Swift_Image::fromPath($fileName));
     } else {
         $image->src = $this->basePath . str_replace(sfConfig::get('sf_web_dir'), '', $fileName);
     }
     return $image;
 }
Beispiel #12
0
 /**
  * Apply the transformation to the image and returns the resized image
  */
 protected function transform(sfImage $image)
 {
     $source_w = $image->getWidth();
     $source_h = $image->getHeight();
     $target_w = $this->width;
     $target_h = $this->height;
     if (is_numeric($this->width) && $this->width > 0 && $source_w > 0) {
         if (!$this->inflate && $target_w > $source_w) {
             $target_w = $source_w;
         }
         if ($this->proportional) {
             // Compute the new height in order to keep the aspect ratio
             // and clamp it to the maximum height
             $target_h = round($source_h / $source_w * $target_w);
             if (is_numeric($this->height) && $this->height < $target_h && $source_h > 0) {
                 $target_h = $this->height;
                 $target_w = round($source_w / $source_h * $target_h);
             }
         }
     }
     if (is_numeric($this->height) && $this->height > 0 && $source_h > 0) {
         if (!$this->inflate && $target_h > $source_h) {
             $target_h = $source_h;
         }
         if ($this->proportional) {
             // Compute the new width in order to keep the aspect ratio
             // and clamp it to the maximum width
             $target_w = round($source_w / $source_h * $target_h);
             if (is_numeric($this->width) && $this->width < $target_w && $source_w > 0) {
                 $target_w = $this->width;
                 $target_h = round($source_h / $source_w * $target_w);
             }
         }
     }
     return $image->resizeSimple($target_w, $target_h);
 }
 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     // Work out where we need to draw to
     $offset = $this->getThickness() / 2;
     $mod = $this->getThickness() % 2;
     $x2 = $image->getWidth() - $offset - ($mod === 0 ? 1 : 0);
     $y2 = $image->getHeight() - $offset - ($mod === 0 ? 1 : 0);
     $image->rectangle($offset, $offset, $x2, $y2, $this->getThickness(), $this->getColor());
     return $image;
 }
Beispiel #14
0
function showThumb_watermark($image_name, $folder, $options = array(), $resize = 'scale', $default = 'default.jpg', $watermark = 'images/watermark.png', $position = 'middle-center')
{
    if (empty($options['alt'])) {
        $options['alt'] = 'image ' . $image_name;
    }
    $image_path = doThumb_watermark($image_name, $folder, $options, $resize, $default, $watermark, $position);
    $img = new sfImage(sfConfig::get('sf_web_dir') . $image_path);
    //récupere les vraies dimensions de l'image du thumb et on écrase dans les options.
    $options['width'] = $img->getWidth();
    $options['height'] = $img->getHeight();
    return image_tag($image_path, $options);
}
 protected function transformDefault(sfImage $image)
 {
     $w = $image->getWidth();
     $h = $image->getHeight();
     $resource = $image->getAdapter()->getHolder();
     $mask = $this->getMask()->getAdapter()->getHolder();
     imagealphablending($resource, true);
     $resource_transparent = imagecolorallocate($resource, 0, 0, 0);
     imagecolortransparent($resource, $resource_transparent);
     // Copy $mask over the top of $resource maintaining the Alpha transparency
     imagecopymerge($resource, $mask, 0, 0, 0, 0, $w, $h, 100);
 }
 /**
  * Apply the opacity transformation to the sfImage object
  * 
  * @param sfImage
  * 
  * @return sfImage
  */
 public function transform(sfImage $image)
 {
     // Get the actual image resource
     $resource = $image->getAdapter()->getHolder();
     //get the resource dimentions
     $width = $image->getWidth();
     $height = $image->getHeight();
     $reflection = $image->copy();
     $reflection->flip()->resize($width, $this->reflection_height);
     $r_resource = $reflection->getAdapter()->getHolder();
     $dest_resource = $reflection->getAdapter()->getTransparentImage($width, $height + $this->reflection_height);
     imagecopymerge($dest_resource, $resource, 0, 0, 0, 0, $width, $height, 100);
     imagecopymerge($dest_resource, $r_resource, 0, $height, 0, 0, $width, $this->reflection_height, 100);
     // Increments we are going to increase the transparency
     $increment = 100 / $this->reflection_height;
     // Overlay line we use to apply the transparency
     $line = imagecreatetruecolor($width, 1);
     // Use white as our overlay color
     imagefilledrectangle($line, 0, 0, $width, 1, imagecolorallocate($line, 255, 255, 255));
     $tr = $this->start_transparency;
     // Start at the bottom of the original image
     for ($i = $height; $i <= $height + $this->reflection_height; $i++) {
         if ($tr > 100) {
             $tr = 100;
         }
         imagecopymerge($dest_resource, $line, 0, $i, 0, 0, $width, 1, $tr);
         $tr += $increment;
     }
     // To set a new resource for the image object
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     $resource_w = $image->getWidth();
     $resource_h = $image->getHeight();
     $scale_w = $this->getWidth() / $resource_w;
     $scale_h = $this->getHeight() / $resource_h;
     $ratio_w = $resource_w / $this->getWidth();
     $ratio_h = $resource_w / $this->getHeight();
     switch ($this->getMethod()) {
         case 'deflate':
         case 'inflate':
             return $image->resize($this->getWidth(), $this->getHeight());
         case 'west':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($this->getWidth(), $this->getHeight(), 0, 0);
         case 'east':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($this->getWidth(), $this->getHeight(), (int) ($image->getWidth() - $this->getWidth()), 0);
         case 'north':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($this->getWidth(), $this->getHeight(), 0, 0);
         case 'south':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($this->getWidth(), $this->getHeight(), 0, $image->getHeight() - $this->getHeight());
         case 'center':
             $image->scale(max($scale_w, $scale_h));
             $left = (int) round(($image->getWidth() - $this->getWidth()) / 2);
             $top = (int) round(($image->getHeight() - $this->getHeight()) / 2);
             return $image->crop($this->getWidth(), $this->getHeight(), $left, $top);
         case 'scale':
         default:
             return $image->scale(min($scale_w, $scale_h));
     }
 }
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // Attempt to calibrate the parameters to Photoshop:
     $amount = $this->getAmount() * 0.016;
     $radius = abs(round($this->getRadius() * 2));
     $threshold = $this->getThreshold();
     $w = $image->getWidth();
     $h = $image->getHeight();
     if ($radius > 0) {
         $imgCanvas = imagecreatetruecolor($w, $h);
         $imgBlur = imagecreatetruecolor($w, $h);
         if (function_exists('imageconvolution')) {
             $matrix = array(array(1, 2, 1), array(2, 4, 2), array(1, 2, 1));
             imagecopy($imgBlur, $resource, 0, 0, 0, 0, $w, $h);
             imageconvolution($imgBlur, $matrix, 16, 0);
         } else {
             // Move copies of the image around one pixel at the time and merge them with weight
             // according to the matrix. The same matrix is simply repeated for higher radii.
             for ($i = 0; $i < $radius; $i++) {
                 imagecopy($imgBlur, $resource, 0, 0, 1, 0, $w - 1, $h);
                 // left
                 imagecopymerge($imgBlur, $resource, 1, 0, 0, 0, $w, $h, 50);
                 // right
                 imagecopymerge($imgBlur, $resource, 0, 0, 0, 0, $w, $h, 50);
                 // center
                 imagecopy($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
                 imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 33.33333);
                 // up
                 imagecopymerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 25);
                 // down
             }
         }
         if ($threshold > 0) {
             // Calculate the difference between the blurred pixels and the original
             // and set the pixels
             // Each row
             for ($x = 0; $x < $w - 1; $x++) {
                 // Each pixel
                 for ($y = 0; $y < $h; $y++) {
                     $rgbOrig = ImageColorAt($resource, $x, $y);
                     $rOrig = $rgbOrig >> 16 & 0xff;
                     $gOrig = $rgbOrig >> 8 & 0xff;
                     $bOrig = $rgbOrig & 0xff;
                     $rgbBlur = ImageColorAt($imgBlur, $x, $y);
                     $rBlur = $rgbBlur >> 16 & 0xff;
                     $gBlur = $rgbBlur >> 8 & 0xff;
                     $bBlur = $rgbBlur & 0xff;
                     // When the masked pixels differ less from the original
                     // than the threshold specifies, they are set to their original value.
                     $rNew = $rOrig;
                     if (abs($rOrig - $rBlur) >= $threshold) {
                         $rNew = max(0, min(255, $amount * ($rOrig - $rBlur) + $rOrig));
                     }
                     $gNew = $gOrig;
                     if (abs($gOrig - $gBlur) >= $threshold) {
                         $gNew = max(0, min(255, $amount * ($gOrig - $gBlur) + $gOrig));
                     }
                     $bNew = $bOrig;
                     if (abs($bOrig - $bBlur) >= $threshold) {
                         $bNew = max(0, min(255, $amount * ($bOrig - $bBlur) + $bOrig));
                     }
                     if ($rOrig != $rNew || $gOrig != $gNew || $bOrig != $bNew) {
                         $pixCol = ImageColorAllocate($resource, $rNew, $gNew, $bNew);
                         ImageSetPixel($resource, $x, $y, $pixCol);
                     }
                 }
             }
         } else {
             // each row
             for ($x = 0; $x < $w; $x++) {
                 // each pixel
                 for ($y = 0; $y < $h; $y++) {
                     $rgbOrig = ImageColorAt($resource, $x, $y);
                     $rOrig = $rgbOrig >> 16 & 0xff;
                     $gOrig = $rgbOrig >> 8 & 0xff;
                     $bOrig = $rgbOrig & 0xff;
                     $rgbBlur = ImageColorAt($imgBlur, $x, $y);
                     $rBlur = $rgbBlur >> 16 & 0xff;
                     $gBlur = $rgbBlur >> 8 & 0xff;
                     $bBlur = $rgbBlur & 0xff;
                     $rNew = $amount * ($rOrig - $rBlur) + $rOrig;
                     if ($rNew > 255) {
                         $rNew = 255;
                     } elseif ($rNew < 0) {
                         $rNew = 0;
                     }
                     $gNew = $amount * ($gOrig - $gBlur) + $gOrig;
                     if ($gNew > 255) {
                         $gNew = 255;
                     } elseif ($gNew < 0) {
                         $gNew = 0;
                     }
                     $bNew = $amount * ($bOrig - $bBlur) + $bOrig;
                     if ($bNew > 255) {
                         $bNew = 255;
                     } elseif ($bNew < 0) {
                         $bNew = 0;
                     }
                     $rgbNew = ($rNew << 16) + ($gNew << 8) + $bNew;
                     ImageSetPixel($resource, $x, $y, $rgbNew);
                 }
             }
         }
         imagedestroy($imgCanvas);
         imagedestroy($imgBlur);
     }
     return $image;
 }