|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-05-18 10:56 UTC] me at reso dot od dot ua
Description: ------------ I'm trying to reproduce the example from http://www.smileygenerator.us/imagick6/quantize/index.html i.e. Dithering with Symbol Patterns The following command works from the command line: convert eyes.gif +matte -colorspace Gray -scale 1600% -negate \ dpat_symbols.gif -virtual-pixel tile -fx 'u[floor(16*u)+1]' \ eyes_syms.gif Reproduce code: --------------- <? $img=new Imagick(); $img->readImage('eyes.gif'); $img->setImageColorspace(Imagick::COLORSPACE_GRAY); $img->setImageMatte(true); $img->scaleImage(288,288); $img->negateImage(false); $src=new Imagick(); $src->readImage('dpat_symbols.gif'); $src->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TILE); $img->addImage($src); $img=$img->fxImage("u[floor(15.9999*u)+1]"); header("Content-type: image/jpeg"); echo $img; ?> Expected result: ---------------- This should produce something like this: http://www.smileygenerator.us/imagick6/quantize/eyes_syms.gif but only one image from gif sequence i.e. 16x16px is shown. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 23:00:02 2025 UTC |
Hi, try something like: <? $img=new Imagick(); $img->readImage('eyes.gif'); $img->setImageColorspace(Imagick::COLORSPACE_GRAY); $img->setImageMatte(true); $img->scaleImage(288,288); $img->negateImage(false); $src=new Imagick(); $src->readImage('dpat_symbols.gif'); $src->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TILE); $img->addImage($src); foreach ($img as $frame) $frame->fxImage("u[floor(15.9999*u)+1]"); header("Content-type: image/jpeg"); echo $img->getImagesBlob(true); ?>Thank you for the reply. Unfortunately this does not work. The thing is IM is using gif as a lookup table and the output is not intended to be animated. It appears that fxImage("u[0]") for instance returns the 16x16 half of eyes.gif instead of complete picture.Although it does not produce the same result as in command line, at least it produces the full size picture: <? $img=NewMagickWand(); MagickReadImage($img,'eyes.gif'); //MagickSetImageAlphaChannel($img,MW_ActiveAlphaChannel); MagickSetImageColorspace($img, MW_GRAYColorspace); MagickScaleImage($img, 288, 288); MagickNegateImage($img); $tmp=NewMagickWand(); MagickSetFormat($tmp,'GIF'); MagickReadImage($tmp,'dpat_symbols.gif'); MagickSetImageVirtualPixelMethod($tmp, MW_TileVirtualPixelMethod); MagickAddImages($img, $tmp); $img = MagickFxImage($img,"u[floor(15.9999*u)+1]"); header("Content-type: image/png"); MagickEchoImageBlob($img); ?> Maybe I'm doing something wrong?