Decimal transformation, and alignment of images

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
gabrielstuff
Posts: 1
Joined: 2016-03-01T00:45:42-07:00
Authentication code: 1151

Decimal transformation, and alignment of images

Post by gabrielstuff »

Hi !
We have a files which contains a series of transform and we would like to know how to use the numbers to correctly move each image associated with its transform.

The parameters use very long decimal numbers for rotate and scale. Not respecting this numbers lead to wrongly aligned elements. See parameters for information :

Code: Select all

{
            "offsetX": -19,
            "offsetY": 78,
            "angle": -0.15183675289154054,
            "scale": 0.995110034942627,
            "cropWidth": 1865,
            "cropHeight": 1112
        },
        {
            "offsetX": 31,
            "offsetY": 107,
            "angle": 357.3140563964844,
            "scale": 1.1337047815322877,
            "cropWidth": 1920,
            "cropHeight": 1168
        },
        {
            "offsetX": -12,
            "offsetY": 129,
            "angle": -1.650545597076416,
            "scale": 1.1337047815322877,
            "cropWidth": 1920,
            "cropHeight": 1165
        }
This correspond to 3 images that need to be offsetted, cropped, rotated and scaled.

Thanks for any help regarding such an accurate transformation.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Decimal transformation, and alignment of images

Post by snibgo »

I would use "-distort SRT". See http://www.imagemagick.org/script/comma ... hp#distort

For example, assuming you want to crop after the scale and rotate:

Code: Select all

convert in.png -distort SRT 0.995110034942627,-0.15183675289154054 -crop 1865x1112-19+78 +repage out.png
snibgo's IM pages: im.snibgo.com
Post Reply