IM 6.6.0-6 - New setting ignored when resetting a mask

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
kankwayot

IM 6.6.0-6 - New setting ignored when resetting a mask

Post by kankwayot »

Hello !


With convert, resetting -mask by reusing the filename of a modified file fails to take the modification into account.


Whilst writing IM commands, I've taken the habit to overwrite my mpr: files when possible so as to hopefully minimize the memory required and not have to hit the o so slower disk with temporary files ; far from being always necessary, I nonetheless consider it a good automatism to have considering how fast things can add up : an oversampling here and there for example and all of a sudden we speak hundreds of megabytes after all.
With regard to the setting and resetting of -mask, doing this worked well in IM 6.4.9-3 2009-02-05 Q8 on Windows XPSP3, but leads to failure in IM 6.6.0-6 2010-03-16 Q16 OpenMP on both Ubuntu 9.10 and Windows XPSP3, as shown by this test :

In a single command,
  • a grayscale image was used to set a mask,
  • it was modified,
  • it was then used to reset the mask.

Code: Select all

convert \
    -size 123x456 \
    gradient:white-black \
        -write mpr:grayscale +delete \
    -mask mpr:grayscale \
    pattern:bricks pattern:checkerboard \
        -compose SrcOver -composite \
        -write fading_1.png +delete \
    mpr:grayscale \
        -transpose \
        -write mpr:grayscale +delete \
    -mask mpr:grayscale -size 456x123 \
    pattern:bricks pattern:checkerboard \
        -compose SrcOver -composite \
        fading_2.png
(Edit: every "tile:pattern:" replaced by the sufficient "pattern:" so as not to set a bad example)

Note: The URLs of the following images are posted here in plain text and not in BBcode because for whatever reason, when editing and previewing this post, instead of being displayed, these URLs were redirected to "bayimg.com" (?!?) whereas the embedding seemed to work well when tried with the logos of (and hosted on) ImageMagick or Wikipedia. Sorry for the inconvenience.


fading_1.png should have been :
http://pixfarm.net/upload/1/originals/a8/a8718f931f7a58b885840748287c8af1.png
.. and it was, as expected ; mpr:grayscale was correctly taken into account the first time it was used.

fading_2.png should have been :
http://pixfarm.net/upload/2/originals/66/66d6f2f271ebfbe36bdd5818def635e6.png
.. instead, it was :
http://pixfarm.net/upload/2/originals/a5/a5e7a22c68d5c558ab82c7cb679bfc8a.png
.. it did not fade ; not only that : convert complained that "image size differs" as if mpr:grayscale had not been modified.


Now, considering that -transpose works well, either overwriting mpr:grayscale failed or the second -mask ignored the modified content of mpr:grayscale.
Having otherwise verified that overwriting a mpr: still worked, it appears that resetting -mask fails when the filename used is unchanged, even if the content of the said file has changed.
Inserting a +mask beforehand being of no avail, a way to cope with the bug was here to create a differently named mpr: for each reset of -mask.


Side note : in the documentation, as of 2010-03-16, -mask is listed as an operator whereas it already appears among the settings.


Thanks for your attention !
Last edited by kankwayot on 2010-03-20T14:53:41-07:00, edited 3 times in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: IM 6.6.0-6 - New setting ignored when resetting a mask

Post by magick »

We can reproduce the problem you reported and have a patch in ImageMagick 6.6.0-7 Beta available by sometime tomorrow. Thanks for the detailed problem report.
kankwayot

Re: [FIXED] - New setting ignored when resetting a mask

Post by kankwayot »

Yessyesyesss : this works ! Thanks !

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Some tangential notes :

i) I've realised that using tile:pattern: was redundant ; using pattern: alone does the job as well, so I've edited the original post to reflect this.

ii) I don't know what kind of importance it can have but I've noticed a gotcha too. It's thanks to dumb luck that I had managed to produce a correct pattern for the test. When designing it, I was not aware that one must be careful of the setting given to -compose before using pattern: (at least in IM 6.6.0-6 and IM 6.6.0-7) :

Code: Select all

convert -size 100x100                  pattern:bricks     a_bricks_pattern.png
convert -size 100x100 -compose SrcOver pattern:bricks     a_bricks_pattern_too.png
convert -size 100x100 -compose Src     pattern:bricks not_a_bricks_pattern.png
.. which vaguely reminds me of having read that it's indeed advised in lengthy commands to reset -compose at SrcOver after use.[/i]
Post Reply