[magick-users] Frustrated with -page

Anthony Thyssen anthony at griffith.edu.au
Tue Jul 11 00:18:11 PDT 2006


Nathanial Ziarek on  wrote...
| My goal is to add a white border and a drop shadow to an image. I
| can't tell you how frustrating it is not to be able to accomplish
| this, but I just don't understand how IM uses "-page" no matter how
| many samples I look at on Anthony's web site.
|
| Here's what I've got so far (ripped pretty much directly from Anthony):
|
All you have to remember is that -page   -set page  and  -repage
effects a 'virtual canvas'.  That is the actual image sits on a larger
area defined by the 'page' at a given 'page offset'

That is all it is...

Its used to...
  * Position images relative to each other when overlaying, or flattening.
  * Save the location of a small sub-image 'cropped' or 'trimmed'
      from a larger original
  * Define how an image moved in complex 'affine' mathematical transformations.
  * Position the frames of a GIF animation, on a larger canvas.

I have been helping debug many IM commands to ensure it correctly
handles images on a larger 'virtual page/canvas'.

The latest operator to be fixed in this regard is "-shave".
See the last example in the
  Shave Examples...
    http://www.cit.gu.edu.au/~anthony/graphics/imagick6/crop/#shave

Note how the image sits on a larger transparent canvas, even though
the actual image itself does not contain any transparency at all.


| convert -page +10+10 pic3.png -bordercolor white -border 10 \( +clone
| -background black -shadow 80x5+0+2 \) -background white +swap -
| flatten tater.png
|
The first -page, addes some extra space in the top left of the invisible
virtual canvas for the next image read in.  This allows the later shadow
effects some extra room in which to spead out the blurry soft shadow it
creates from the copy of the image.  The image it creates is larger
and with a different 'virtual canvas offset', thus when the images
are flattened together on top of a 'white' background, the top and left
parts of the added shadow will not be junked, due to be negative.

See
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/convolve/#shadows

NOTE: you should also use  -mosaic  rather than  -flatten
so that shadow can also expand the final image size at the bottom-right
as well.

See Mosaic
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/mosaics/#mosaic

Which expands the final image in the down and right directions to hold
all the images.   Using  -flatten  does NOT do this, and that may be
your problem.

| I want the drop shadow to go straight down - I don't want it off to
| the left or right.
|
Than you must use a much smaller blur amount that the offset you give
otherwise it will expand left and upward as well.

EG  5  must be smaller and the 2 must be larger (about twice as large!)

For example...
This some does not need the top-left page...

  convert pic3.png -bordercolor white -border 10 \
          \( +clone -background black -shadow 80x3+0+6 \) \
          -background white +swap -mosaic tater.png

The image will expand only downward by  6 + 3*2 pixels  or 12 pixels
it will NOT expand upward.

Adjust the transparency percentage (80) to make it darker (100)
or lighter (60) as needed.


| This command gives me something tantalizingly
| close, but pushes the right/lower end of the image right off the
| image.

Use -mosaic to expand thge lower right parts to fit the generated
shadow.  The -page only adds space to the top-left side of the original
image.  You can use -chop later to remove some extra space, if not
wanted.

Note a -page is not needed for many images with a shape transparency as
the transparency itself provides the top-left space needed, if it is
needed.

| If I do a "normal" drop shadow (one that looks like the light
| source is at the upper-left  and the shadow is at the lower right) it
| works no problem. However, I can not find any way to "pad" the image
| to get the entire shadow showing.
|
| Seems simple. Why does it have to be so complex?
|
It is complex because shadow HAS to enlarge the original image,
including toward the top left sides.  It also has to be underneath the
original image.

At least it is a lot better than tring to create semi-transparent
shadows using blurs.



Currently even "montage" does not generate 'shaped' shadows.  It fakes
it by overlaying two rectangles of semi-transparent colors, even when
the image has transparency making it non-rectangular!

See near the end of
  Montage, Background and Transparency Handling...
    http://www.cit.gu.edu.au/~anthony/graphics/imagick6/montage/#bg

The fix is a long term 'future proposal'.
   http://www.cit.gu.edu.au/~anthony/graphics/imagick6/bugs/future/#montage_shadows

But nothing has been done in this area.  Prehaps you can try to add it
:-)


  Anthony Thyssen ( System Programmer )    <A.Thyssen at griffith.edu.au>
 -----------------------------------------------------------------------------
   Writing software takes twice as long as you expect it will take...
                  Even if you keep this in mind!
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/


More information about the Magick-users mailing list