Using %[fx:] with -repage

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jules43
Posts: 11
Joined: 2015-09-01T06:14:31-07:00
Authentication code: 1151

Using %[fx:] with -repage

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using %[fx:] with -repage

Post by snibgo »

"-repage" can't accept expressions.
snibgo's IM pages: im.snibgo.com
jules43
Posts: 11
Joined: 2015-09-01T06:14:31-07:00
Authentication code: 1151

Re: Using %[fx:] with -repage

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using %[fx:] with -repage

Post 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.
snibgo's IM pages: im.snibgo.com
jules43
Posts: 11
Joined: 2015-09-01T06:14:31-07:00
Authentication code: 1151

Re: Using %[fx:] with -repage

Post by jules43 »

Thank-you for your help
Post Reply