Menu

#633 MagickSetSamplingFactors() API mismatch - comma separated values instead of 1x1

v1.0_(example)
closed-fixed
None
5
2020-09-20
2020-08-10
No

Looking at the GraphicsMagic code, the gm tool sets the scaling_factor in the ImageInfo structure by setting a set of comma separated tokens like this:

0x0[,0x0,0x0,0x0]

There is also a function in the gm command tool called NormalizeSamplingFactor that converts Y:U:V to 0x0.

The MagickSetSamplingFactors() function however accepts a list if doubles, which are then converted into comma separated values, like this:

0,0,0,0

Either I'm going mad or this makes no sense. Googling for MagickSetSamplingFactors doesn't seem to show any code that uses this API, so it could be people have tried to use it, seen it doesn't work, and ignored it.

Is this a bug, or am I reading the code wrong?

The reason it matters is that the MagickWand API doesn't allow any access to the ImageInfo structure, so there seems no sane way to set the sampling factors in the MagickWand.

Discussion

  • Bob Friesenhahn

    Bob Friesenhahn - 2020-08-10

    On Mon, 10 Aug 2020, Graham Leggett wrote:

    The MagickSetSamplingFactors() function however accepts a list if doubles, which are then converted into comma separated values, like this:

    0,0,0,0

    Either I'm going mad or this makes no sense. Googling for MagickSetSamplingFactors doesn't seem to show any code that uses this API, so it could be people have tried to use it, seen it doesn't work, and ignored it.

    Is this a bug, or am I reading the code wrong?

    This MagickSetSamplingFactors() implementation was slurped in from the
    early ImageMagick Wand implementation dating from December, 2003. At
    that time ImageMagick was still using a license which is compatible
    with the license GraphicsMagick uses. It seems that in a mere year
    (since the fork), ImageMagick had already changed how it internally
    stores sampling factors. These sort of subtle/spurious changes are
    why GraphicsMagick came to be!

    The reason it matters is that the MagickWand API doesn't allow any
    access to the ImageInfo structure, so there seems no sane way to set
    the sampling factors in the MagickWand.

    Sorry about that. It may be that you are the first to try to use this
    function, or it may be that 99% of the people who encountered the
    issue failed to file a bug report and you are the first to do so.

    Bob

    Bob Friesenhahn
    bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
    GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
    Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2020-09-20
    • status: open --> closed-fixed
    • assigned_to: Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2020-09-20

    This problem is fixed by Mercurial changeset 16339:7a86c56bc6aa. Thanks very much for reporting it.

     

Log in to post a comment.

MongoDB Logo MongoDB