distort:viewport

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
dummzeuch
Posts: 3
Joined: 2019-10-23T02:26:37-07:00
Authentication code: 1152

distort:viewport

Post by dummzeuch » 2019-10-23T02:41:06-07:00

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.

dummzeuch
Posts: 3
Joined: 2019-10-23T02:26:37-07:00
Authentication code: 1152

Re: distort:viewport

Post by dummzeuch » 2019-10-23T03:11:56-07:00

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!

snibgo
Posts: 12272
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: distort:viewport

Post by snibgo » 2019-10-23T05:36:11-07:00

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.
snibgo's IM pages: im.snibgo.com

dummzeuch
Posts: 3
Joined: 2019-10-23T02:26:37-07:00
Authentication code: 1152

Re: distort:viewport

Post by dummzeuch » 2019-11-08T05:33:11-07:00

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.

Post Reply