marckyL wrote:AH. Ok. I think I solved my problem. It seems it's much easier to use SRT for the scale, and move the viewport accordingly for the 'panning'. Is there anything inherently wrong with this approach?
That means you do two operations on the image. Though as long as the panning involves only whole numbers (not sub-pixel moves - and yes SRT can move images a 'part of a pixel') and you select a filter that does NOT blur the image, than that should be no problem.
Remember "distort" uses a 2 Dimentional filter, which due to diagonals, are not perfect pixel preservation in a NO-OP distortion
See No-Op Distortions
http://www.imagemagick.org/Usage/distorts/#distort_noop
Better still do the 'panning' using viewport to avoid a second distort filter of the image. OR do it as a single step.
Essentially a viewport is like a '-crop' or '-extent', but does it by defining what pixels it needs to distort from the destination mage into the source images (which is just the way distort works!).
SRT distortion rotates and scales the image around the first coordinate given. That coordinate then gets moved to the final coordinate (if given).
NOTE -distort basically defines the viewport to be the same is the input image (except in polar distorts which uses a +distort viewport anyway)
+disport tries to work out what the best 'viewport' to capyure the whole distorted image, if possible. If it can't work it out (EG shepards Distortion) it falls back to using -distort (eg the original image as the viewport). Setting "distort:viewport" simply overrides the -/+distort viewport selection, in which case it does not matter which form of the operator you use.
The viewport defines how much and what part of the image you want to see. Especially if you JUNK the virtual canvas at the end which in practical terms just pans the image so the top left corner of the viewport becomes 0,0. In other terms. If you are providing a viewport, AND moving the center of rotation and scaling, and junking the virtual canvas. you may as well defind a viewport located at +0+0 of the size you want, and SRT position the center of roatation where you want on that viewport.
The major difference between using SRT (actually a Affine Transform) for panning VS crop/viewport/virtual canvas offset is that SRT can as part of its process do sub-pixel moves of the image. The others are limited to whole pixel moves.
It is the same for scaling using SRT rather than resize/scale. Resize limits the final size to whole pixels, while SRT lets you scale using any scale factor you want. But it is still better to use SRT to do both operations together... scale and panning (sub-pixel positioning)
SRT, Affine (2 or 3 point), and Affine Projection (matrix) are all the same operation. scale, rotate, panning...
The later distortions (3 point or projection) also adds shear and aspect ratio components to the distortions.