Page 1 of 1

Using %[fx:] with -repage

Posted: 2015-09-01T06:23:58-07:00
by jules43
I'm using the Windows Commandline version of Convert and I have a batch file that contains the following command:

Code: Select all

convert^
 -virtual-pixel horizontal-tile-edge^
 -verbose^
 %1^
 ^( -clone 0^
  -set option:distort:viewport "%%[fx:w/2]x%%[fx:h]+0+0"^
  -distort affine "0,0,0.5,0.5,%%[fx:w/2],%%[fx:h],%%[fx:w/2-0.5],%%[fx:h-0.5]"^
  -repage "+%%[fx:w]+0"^
 ^)^
 ^( -clone 0^
  -set option:distort:viewport "%%[fx:w/2]x%%[fx:h]+%%[fx:w/2]+0"^
  -distort affine "%%[fx:w/2],0,%%[fx:w/2+0.5],0.5,%%[fx:w],%%[fx:h],%%[fx:w-0.5],%%[fx:h-0.5]"^
  -repage +0+0^
 ^)^
 -delete 0^
 -layers merge^
 +repage^
 %2
I get the error "convert.exe: invalid argument for option '-repage': ^+%[fx:w]^+0 @ error/convert.c/ConvertImageCommand/2551

If I replace +%%[fx:w] with a number (512 say) then the command behaves as expected. Elsewhere in the command I use %%[fx:... successfully, but I don't seem able to use it with -repage.

Can anyone spot what I'm doing wrong?

Thanks

Convert -version produces:

Version: ImageMagick 6.9.2-0 Q16 x64 2015-08-15 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

Re: Using %[fx:] with -repage

Posted: 2015-09-01T06:34:46-07:00
by snibgo
"-repage" can't accept expressions.

Re: Using %[fx:] with -repage

Posted: 2015-09-01T06:39:20-07:00
by jules43
I've fixed this by replacing -repage with -set page and the same arguments.

Can anyone tell me what the difference in meaning between -repage and -set page is?

It's clear that snibgo's statement that -repage can't accept expressions is correct. Is that the expected behaviour? I didn't see anything in the docs indicating this.

Thanks again

Re: Using %[fx:] with -repage

Posted: 2015-09-01T07:50:03-07:00
by snibgo
jules43 wrote:It's clear that snibgo's statement that -repage can't accept expressions is correct. Is that the expected behaviour? I didn't see anything in the docs indicating this.
It would be useful if, everywhere that IM syntax accepted numbers, it also accepted arithmetic expressions. Sadly it doesn't. The ability for some operations to accept expressions has been slowly added over the years. Documentation such as http://www.imagemagick.org/script/comma ... php#repage generally says if expressions are allowed. If it doesn't say, then it (probably) isn't allowed.
jules43 wrote:Can anyone tell me what the difference in meaning between -repage and -set page is?
Good question. I think the only difference is that "-set page" accepts expressions, but I'm happy to be corrected.

Re: Using %[fx:] with -repage

Posted: 2015-09-02T09:08:09-07:00
by jules43
Thank-you for your help