I am trying to rectify a perspective photograph with ImageMagick in a CMD batch file under Windows, picking the image coordinates from the photograph and supplying the world coordnates in centimeters. I have to extend the canvas if the world coordinates exceed the image dimensions:
Code: Select all
magick %1 -gravity northwest -extent %EXT% -virtual-pixel white -distort perspective "%B1% %W1% %B2% %W2% %B3% %W3% %B4% %W4%" -trim -flip test.jpg
I set the %EXT% paramter to the larger dimensions of the original photo and the target image: If the original photograph has for example 1000x2000 pixel and the target image needs to be 500x3000 pixel, I would like to set %EXT% to 1000x3000 pixel.
I did not succeed by using the modifyer -extent 500x3000< and thus performed the task of setting %EXT% correctly within the CMD batch file.
Could you think of a more elegant way to do the trick?