Mapping IM commands , reduce red channell for 'red eye'

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
monsters

Mapping IM commands , reduce red channell for 'red eye'

Post by monsters »

Hi there, this works dandy in ImageMagick CLI

convert red-eye.jpg -region 24x14+72+115 -channel red -modulate 100,70 output.jpg


I can't for the life of me figure out how to duplicate this in MagickWand

Any help appreciated.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

[edit]Oooops. I meant to reply to your post in the MagickWand forum. Oh well.

I think this does what you wanted :-)
I'd be interested if anyone has a better/alternate method.

Pete

Code: Select all

	MagickWand *magick_wand = NULL,*region_wand = NULL;
	int dx,dy,x,y;

	MagickWandGenesis();

	magick_wand = NewMagickWand();
	MagickReadImage(magick_wand,"magick.jpg");

	// Specify the region's (x,y) coordinate
	x = 115;
	y = 25;
	// and its width and height
	dx = 40;
	dy = 40;
	// and extract it
	region_wand = MagickGetImageRegion(magick_wand,dx,dy,x,y);
	// Modulate the region
	MagickModulateImage(region_wand,50,70,0);
	// and now copy the red channel back
	MagickCompositeImageChannel(magick_wand,RedChannel,region_wand,CopyCompositeOp,x,y);

	MagickWriteImage(magick_wand,"magick_red_eye.jpg");

	/* Clean up */
	if(magick_wand)magick_wand = DestroyMagickWand(magick_wand);
	if(region_wand)region_wand = DestroyMagickWand(region_wand);
	MagickWandTerminus();
monsters

Hmm

Post by monsters »

well, that technique is a start, i end up with some very green images..

currently trying to figure out
MagickFxImage , which it would seem nobody has ever used before.. ever. 8)

Doesn't seem to matter what i pass in, it doesn't do anything..


I was tring fx strings, like this
MagickFxImage( $region_wand, "u.r /2",MW_RedChannel );

but quickly realised it did nothing, and neither does this
MagickFxImage( $region_wand, "xxxxxxxxxxxxxxxxxxxxxx",MW_RedChannel );



MagickWand is really, really cryptic, and almost not documented at all... I'm pretty surprised by all that..
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Did you try
  • fx_wand = MagickFxImageChannel( $region_wand, "u /2", MW_RedChannel );
MagickFxImageChannel() returns a wand and leaves the original image sequence untouched.
Last edited by magick on 2006-12-01T07:47:42-07:00, edited 1 time in total.
monsters

i did.

Post by monsters »

It's great to see an admin involved!!

I did, it would seem , to me, that the magickwand api returns a wand, but that the php implementation of it actually returns a magickwand boolean (true | false )

I've found this discrepency in other areas as well..

I will double check though.
monsters

Post by monsters »

I ended up solving this by doing a pixel iteration and replacing the red pixels with non red pixels, i can't post the actual formula due to my NDA's and such, but the formula was not a complicated one.

I never could get the fx commands to work.
Post Reply