working with shadows - repaging?

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
tsr

working with shadows - repaging?

Post by tsr »

Currently I'm doing something like:

Code: Select all

function addShadow($wand) {
  $clone = CloneMagickWand($wand);
  $shadowColor = NewPixelWand('black');
  $backgroundColor = NewPixelWand('white');
  MagickSetImageBackgroundColor($clone, $shadowColor);
  MagickShadowImage($clone,50,3,0,0);
  MagickAddImage($wand, $clone);
  DestroyMagickWand($wand);
  MagickSetImageBackgroundColor($clone,$backgroundColor);
  $wand = MagickMosaicImages($clone);
}

addShadow($wand);
MagickBorderImage($wand, NewPixelWand('white']), 10, 10);
addShadow($wand);
The result is a enlarged image that doesn't have shadow on the upper and left sides. Neither below the original image nor the frame. I wonder how I can repage the image before applying the MagickShadowImage function as suggested at the IM v6 example site?

If anyone has any other suggestion on how to apply a shadow that can run on all sides I'd be extremely grateful.

/tsr
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: working with shadows - repaging?

Post by magick »

We added MagickResetImagePage() to replicate the functionality of the -repage option. It will be available in ImageMagick 6.3.3 Beta and MagickWandForPHP 1.0.2 Beta tommorrow.
tsr

Re: working with shadows - repaging?

Post by tsr »

Thanks!

Seeing how fast you fix things I wonder if I may take the opportunity to make a feature request for a function:

MagickWand MagickConvert(string)

This function should return the resulting image of a regular cli convert command as a MagickWand with the added twist that any wand resources are dealt with (eg writing tmp files to disk) this way, there is always a nice fallback function whenever 1. the functionality is lacking 2. you find a way to do something as a cli-command and while you wait for Mr. Magick to show you how easy it is to do it in MW you don't have to sit and wait and halt the progress of your code :)

I think I'll code this up in php right now :)

/tsr
tsr

Re: working with shadows - repaging?

Post by tsr »

magick wrote: We added MagickResetImagePage() to replicate the functionality of the -repage option. It will be available in ImageMagick 6.3.3 Beta and MagickWandForPHP 1.0.2 Beta tommorrow.


Ok, I finally decided to recompile my environment and get the latest stable code.

I can't really say I understand how to use it.

This:

Code: Select all

MagickCropImage($this->wand, $width, $height, $xOffset, $yOffset);
MagickResetImagePage($this->wand, $width.'x'.$height.'+'.$xOffset.'+'.$yOffset);
(no mather what the second argument is I get the same result, the only difference being that the 'Image' property is set to whatever the second argument is set to)

Still has the 'Page Geometry' property different than the 'Geometry' property. While (cliConvert just being a wrapper function that handles file-operations):

Code: Select all

MagickCropImage($this->wand, $width, $height, $xOffset, $yOffset);
$this->cliConvert('convert +repage %1$s %1$s');
Actually repages the image so that 'Geometry' == 'Page Geometry'.

Maybe a bug or maybe I'm using it wrong, no idea, and hard to find out since it isn't documented.

Now looking at the code it seems the only thing happening is that 'MagickSetImageFilename' is invoked in different ways depending on if there is a second argument or not, seems strange.

/tsr

ps. the reason why I decided to try out this approach (using MagickResetImagePage) is that I'm having trouble passing around the wand resources and also prefer to use one interface rather than 2.
Post Reply