php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58678 fxImage
Submitted: 2009-05-18 10:56 UTC Modified: 2009-06-04 16:05 UTC
From: me at reso dot od dot ua Assigned:
Status: Not a bug Package: imagick (PECL)
PHP Version: 5.2.9 OS: Ubuntu LTS 8.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: me at reso dot od dot ua
New email:
PHP Version: OS:

 

 [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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-18 11:28 UTC] mkoppanen@php.net
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);

?>
 [2009-05-18 15:15 UTC] me at reso dot od dot ua
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.
 [2009-05-22 03:59 UTC] me at reso dot od dot ua
I have tried the similar code with MagickWand API and it works 
ok.
 [2009-05-23 07:12 UTC] mkoppanen@php.net
Hi, 

can you paste the MagickWand code you are trying?
 [2009-05-23 07:17 UTC] me at reso dot od dot ua
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?
 [2009-06-04 16:05 UTC] mkoppanen@php.net
Sorry, but your problem does not imply a bug in PECL itself.  For a
list of more appropriate places to ask for help using PECL, please
visit http://pecl.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PECL.

Not sure if this is an actual bug or more of a usage issue. Have you tried asking on ImageMagick forums? 

This seems to be quite close to your MagickWand example:

<?php

$im = new Imagick('eyes.gif');
$im->setImageColorSpace(Imagick::COLORSPACE_GRAY);

$im->resizeImage(288, 288, imagick::FILTER_LANCZOS, 0.2);
$im->setImagePage(288,288, 0, 0);
$im->negateImage(false);

$tmp = new Imagick('dpat_symbols.gif');
$tmp->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TILE);

foreach ($tmp as $frame) {
        $im->addImage($frame->fxImage("u[floor(15.9999*u)+1]", -1));
}

header("Content-type: image/gif");
echo $im->getImagesBlob();
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 09:01:29 2024 UTC