annotate and mpr

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
bablokb
Posts: 29
Joined: 2005-06-11T06:21:59-07:00

annotate and mpr

Post by bablokb »

Hi,

I have an (automatically) generated IM command which reads an image, and applies some operator with varying arguments to a given number of "slices" of the image, e.g.:

Code: Select all

convert input.jpg -respect-parenthesis \
                  -fill red \
                  -font Arial -pointsize 15 \
            -write mpr:orig +delete \
     \( \
        \( mpr:orig\[522x3900+0+0\] -tint 0  \
                                    -gravity South \
                                    -fill black \
                                    -splice 0x18 \
                                    -annotate 0x0+0+0 '-tint 0' \
        \) \
        \( mpr:orig\[522x3900+522+0\] -tint 25.000  \
                                    -gravity South \
                                    -fill black \
                                    -splice 0x18 \
                                    -annotate 0x0+0+0 '-tint 25.000' \
        \) +append \
        \( mpr:orig\[522x3900+1044+0\] -tint 50.000  \
                                    -gravity South \
                                    -fill black \
                                    -splice 0x18 \
                                    -annotate 0x0+0+0 '-tint 50.000' \
        \) +append \
        \( mpr:orig\[522x3900+1566+0\] -tint 75.000  \
                                    -gravity South \
                                    -fill black \
                                    -splice 0x18 \
                                    -annotate 0x0+0+0 '-tint 75.000' \
        \) +append \
        \( mpr:orig\[522x3900+2088+0\] -tint 100.000  \
                                    -gravity South \
                                    -fill black \
                                    -splice 0x18 \
                                    -annotate 0x0+0+0 '-tint 100.000' \
        \) +append \
     \)  output.jpg
The example tints the slices with increasing strength. Now the script should also annotate each slice, but it only generates the annoation for "-tint 50.000". If I remove the geometry settings for mpr:orig the annoation works fine, but of course I have a different image (five times the original, no slices).

Seems to me that annotate gets confused with the geometry-settings of the mpr:orig (same effect with draw).

My IM version is 6.4.3

Bernhard
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: annotate and mpr

Post by anthony »

Add a +repage afetr each mpr: read.

The read does a 'crop' of the image and as such it leaves the image with a virtual canvas and offset (a layer image). -annotate draws on the virtual canvas so is centered on the virtual canvas, and not the actual image.

+repage resets the virtual cnavs and offset to match the image, making it a 'normal' un-layered image again.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply