SPARSECOLORMETHOD_BARYCENTRIC problem

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
shirkavand
Posts: 8
Joined: 2013-02-04T08:06:40-07:00
Authentication code: 6789

SPARSECOLORMETHOD_BARYCENTRIC problem

Post by shirkavand »

I want to execute the next imageMagick command using IMagick:

Code: Select all

convert girl.jpg -sparse-color barycentric '0,0 black 319,0 white' out.jpg
So, i ended with:

Code: Select all

$firstImage = new imagick( "girl.jpg" ); 
$firstImage->sparseColorImage(Imagick::SPARSECOLORMETHOD_BARYCENTRIC, array( 0, 0, "black", 319, 0, "white"));
$firstImage->writeImage("./out.jpg");
but nothing happens, the out.jpg images is just like the original. Any idea?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SPARSECOLORMETHOD_BARYCENTRIC problem

Post by fmw42 »

I suspect that Imagick has not been upgraded to include that an many other IM changes since the last version of Imagick was released.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: SPARSECOLORMETHOD_BARYCENTRIC problem

Post by anthony »

The API's do not use the routine I use to parse a single string with colornames to a array of numbers (with the right counts accoding to the image and channel setting).

Originally the routine that does this was in the 'core' library so that it would be available for parsing a 'single string argument' but this was then moved into the command parser and made static to that module only. This was not my doing, and I has misgivings about that specific move.

As a consequence you have to specify each of the color as purely an array of numbers, without the colorname conversion :-(

what numbers (floating point) are needed for each color depends on the intersection of the 'channel' setting and the channels present in the image. Whcih as you can immagine can be a little tricky to handle.

It is posible the API you are using could be set up to handle an array such as you have specified, but currently that is not the case.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply