Page 1 of 1

distort:viewport

Posted: 2019-10-23T02:41:06-07:00
by dummzeuch
Hi,

I have got the following magick command line which I want to convert to DLL calls:

Code: Select all

@echo off
set MAGICK=PathToMagickExe

set IN=InputFilename
set OUT2=OutputFilename

rem TLS = top left source
rem TLT = top left target
rem TRS = top right source
rem ...
rem BLT = bottom left target

set TLS=0.5,18.5
set BLS=0.5,464.5
set TRS=639.5,42.5
set BRS=639.5,445.5

set TLT=0.5,30.5
set BLT=0.5,460.5
set TRT=639.5,30.5
set BRT=639.5,460.5

set VIEWPORT=640x431+0+30
set COORDS2="%TLS% %TLT% %TRS% %TRT% %BRS% %BRT% %BLS% %BLT%"
%MAGICK% %IN% -define distort:viewport=%VIEWPORT% -distort Perspective %COORDS2% +repage %OUT2%
The command line produces exactly what I want.

I also have got the basic code for the DistortImage call:

Code: Select all

MagickDistortImage(wand, PerspectiveDistortion, 16, Params, false);
But I can't figure out the API equivalent of the -define distort:viewport=%VIEWPORT% part.

Any pointers would be appreciated.

Re: distort:viewport

Posted: 2019-10-23T03:11:56-07:00
by dummzeuch
I found one solution, but maybe not the best:

Code: Select all

NewWand = MagickGetImageRegion(Wand, 640, 431, 0, 30);
The resulting picture is now binary identical to the one the command line creates.

But there must be a faster way than creating a copy of the picture!

Re: distort:viewport

Posted: 2019-10-23T05:36:11-07:00
by snibgo
dummzeuch wrote:But I can't figure out the API equivalent of the -define distort:viewport=%VIEWPORT% part.
I would guess:

Code: Select all

SetImageProperty(wand->images,"distort:viewport","640x431+0+30",wand->exception);
If this returns false, something bad happened.

Re: distort:viewport

Posted: 2019-11-08T05:33:11-07:00
by dummzeuch
snibgo wrote:
2019-10-23T05:36:11-07:00
I would guess:

Code: Select all

SetImageProperty(wand->images,"distort:viewport","640x431+0+30",wand->exception);
If this returns false, something bad happened.
Thanks. Sorry for not getting back to you earlier. I started a project using ImageMagick but got side tracked afterwards. I have no idea when I will find the time to test your suggestion.