eliminating the offset when using blur in a shadow

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

eliminating the offset when using blur in a shadow

Post by javismiles »

im doing shadows in image texts successfully, the problem comes when i use enough blur , like x4 or x5, then the resulting image jumps from the previous one,
i read that +repage is supposed to reset the offset, but it doesnt seem to work
in the latest version, other people saying the same, any tips?

basically i need that the original image, and the new image with the drop shadow, stay in the same place, so that there is no offset when the shadow
has a blur value

thank u very much
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: eliminating the offset when using blur in a shadow

Post by javismiles »

this is the command i use

convert -background none -fill #ffffff -font Arial -pointsize 100 -rotate 0 -gravity West label:"text" ( -clone 0 -background black -shadow 100x1+2+2 ) -reverse -background none -layers merge +repage result.png

it works great, but the resulting image moves with an offset from its previous position, i just need to eliminate that offset created by the Blur setting of the shadow

thank you very much
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: eliminating the offset when using blur in a shadow

Post by javismiles »

im having another problem

when using Rotate mixed with shadow in that command, only the shadow rotates, not the image,
how could i solve this?

convert -background none -fill #ffffff -font Arial -pointsize 100 -rotate 90 -gravity West label:"text" ( -clone 0 -background black -shadow 100x1+2+2 ) -reverse -background none -layers merge result.png

thank u very much
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: eliminating the offset when using blur in a shadow

Post by javismiles »

i have managed to do the rotate well now, just moving the rotate to the end of command

so only problem i have left is that the shadow that has blur generates a bigger result image than the shadow that has no blur, is there a way to generate the same
sized image with and without blur in the shadow?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: eliminating the offset when using blur in a shadow

Post by anthony »

The image moved because you removed the 'negative' offset that -layers merge generated in order to properly align both images together correctly without clipping the negative parts of the image.

Replace the -layers merge with -mosaic, and the negative offset will be ignored (and clipped). No need for the +repage either.
This is explained in IM Examples, Shadows and the Offset Problem
http://www.imagemagick.org/Usage/blur/#shadow_offset

If the original image has enough padding to take the generated shadow (without too much clipping) then using DstOver composition (to underlay the shadow) is the best method to use.

Code: Select all

  convert rose: -bordercolor None -border 10x10 \
          \( +clone -background navy -shadow 80x3+5+5 \) \
          -compose DstOver -composite -compose Over  shadow_space.png
This example "shadow of a padded image" has been added the above location.


Layer methods in summery...
-layer merge expands the first image bounds in all directions (including negatives)
-mosaic only expands in positive directions and include origin (0,0)
-flatten just uses the size of the first images virtual canvas.
-composite two images only, destination image size preserved

See ImageMagick Usage Examples, Layering Images
http://www.imagemagick.org/Usage/layers/#flatten
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: eliminating the offset when using blur in a shadow

Post by javismiles »

Anthony , this is fantastic help, it works,
thank you very much,
your explanations are always so detailed and well explained,
you really help people a lot in this forum, thank you so much :)
Jav
;)
Post Reply