private function renderDistanceEuclidian() { $canvas = new \Imagick(); $canvas->newPseudoImage(500, 300, "canvas:none"); $canvas->setImageFormat('png'); $shadow = clone $canvas; $text = clone $canvas; $this->drawText($text); $this->drawText($shadow, true); if (false) { $highlight = $this->getSilhouette($text); $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_EUCLIDEAN, "1"); $highlight->morphology(\Imagick::MORPHOLOGY_DISTANCE, 1, $kernel); $highlight->autoLevelImage(); $highlight->evaluateimage(\Imagick::EVALUATE_MULTIPLY, 0.6); $highlight->evaluateimage(\Imagick::EVALUATE_ADD, 0.2 * \Imagick::getQuantum()); $highlight->levelImage(0.2, 1.4, 0.6); $text->compositeimage($highlight, \Imagick::COMPOSITE_MODULATE, 0, 0); } if (true) { $edge = $this->getSilhouette($text); $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "2"); $edge->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel); $edge->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0); } $canvas->compositeImage($shadow, \Imagick::COMPOSITE_COPY, 0, 0); $canvas->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0); header("Content-Type: image/png"); echo $canvas->getImageBlob(); }
public function renderCustomImage() { $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_RING, "2,3.5"); $imagick = renderKernel($kernel); header("Content-Type: image/png"); echo $imagick->getImageBlob(); }
public function render() { //Example ImagickKernel::addUnityKernel $matrix = [[-1, 0, -1], [0, 4, 0], [-1, 0, -1]]; $kernel = \ImagickKernel::fromMatrix($matrix); $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE); $output = "Before adding unity kernel: <br/>"; $output .= renderKernelTable($kernel->getMatrix()); $kernel->addUnityKernel(0.5); $output .= "After adding unity kernel: <br/>"; $output .= renderKernelTable($kernel->getMatrix()); $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE); $output .= "After renormalizing kernel: <br/>"; $output .= renderKernelTable($kernel->getMatrix()); return $output; //Example end }
function renderFontEffect() { $canvas = new \Imagick(); $canvas->newPseudoImage(500, 300, "canvas:none"); $canvas->setImageFormat('png'); $shadow = clone $canvas; $text = clone $canvas; drawText($text); drawText($shadow, true); $edge = getSilhouette($text); $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "2"); $edge->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel); $edge->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0); $canvas->compositeImage($shadow, \Imagick::COMPOSITE_COPY, 0, 0); $canvas->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0); header("Content-Type: image/png"); echo $canvas->getImageBlob(); }
public function render() { //Example ImagickKernel::separate $matrix = [[-1, 0, -1], [0, 4, 0], [-1, 0, -1]]; $kernel = \ImagickKernel::fromMatrix($matrix); $kernel->scale(4, \Imagick::NORMALIZE_KERNEL_VALUE); $diamondKernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DIAMOND, "2"); $kernel->addKernel($diamondKernel); $kernelList = $kernel->separate(); $output = ''; $count = 0; foreach ($kernelList as $kernel) { $output .= "<br/>Kernel {$count}<br/>"; $output .= Display::renderKernelTable($kernel->getMatrix()); $count++; } return $output; //Example end }
function render() { //Example ImagickKernel::scale $output = ""; $matrix = [[-1, 0, -1], [0, 4, 0], [-1, 0, -1]]; $kernel = \ImagickKernel::fromMatrix($matrix); $kernelClone = clone $kernel; $output .= "Start kernel<br/>"; $output .= renderKernelTable($kernel->getMatrix()); $output .= "Scaling with NORMALIZE_KERNEL_VALUE. The <br/>"; $kernel->scale(2, \Imagick::NORMALIZE_KERNEL_VALUE); $output .= renderKernelTable($kernel->getMatrix()); $kernel = clone $kernelClone; $output .= "Scaling by percent<br/>"; $kernel->scale(2, \Imagick::NORMALIZE_KERNEL_PERCENT); $output .= renderKernelTable($kernel->getMatrix()); $matrix2 = [[-1, -1, 1], [-1, false, 1], [1, 1, 1]]; $kernel = \ImagickKernel::fromMatrix($matrix2); $output .= "Scaling by correlate<br/>"; $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_CORRELATE); $output .= renderKernelTable($kernel->getMatrix()); return $output; //Example end }
function createFromMatrix() { $matrix = [[0.5, 0, 0.2], [0, 1, 0], [0.9, 0, false]]; $kernel = \ImagickKernel::fromMatrix($matrix); return $kernel; }
private function renderDistanceIterative() { //Example ImagickKernel::morphology $canvas = $this->getCharacterOutline(); $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "2"); $canvas->morphology(\Imagick::MORPHOLOGY_ITERATIVE, 3, $kernel); $canvas->autoLevelImage(); header("Content-Type: image/png"); echo $canvas->getImageBlob(); //Example end }
function filter($imagePath) { $imagick = new \Imagick(realpath($imagePath)); $matrix = [[-1, 0, -1], [0, 5, 0], [-1, 0, -1]]; $kernel = \ImagickKernel::fromMatrix($matrix); $strength = 0.5; $kernel->scale($strength, \Imagick::NORMALIZE_KERNEL_VALUE); $kernel->addUnityKernel(1 - $strength); $imagick->filter($kernel); header("Content-Type: image/jpg"); echo $imagick->getImageBlob(); }