Offset behaviour with -page, -set page

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
codelad
Posts: 3
Joined: 2018-08-30T01:29:56-07:00
Authentication code: 1152

Offset behaviour with -page, -set page

Post by codelad »

Been tearing my hair off trying to understand this '-page', '-set page' behaviour:

convert -version
Version: ImageMagick 7.0.8-10 Q16 x86_64 2018-08-19

00. Expected behaviour (as far as I understand):
convert -delay 100 -page 100x100+0+0 \( rose: -set page +50+50 \) rose: rose_00.gif

01. Expected same result as 00, but somehow the offset does not apply:
convert -delay 100 -page 100x100+0+0 rose: \( rose: -set page +50+50 \) rose_01.gif

02. Strangely, this works as expected:
convert -delay 100 -page 100x100+0+0 rose: -negate \( rose: -set page +50+50 \) rose_02.gif

03. While here again the offset does not apply:
convert -delay 100 -page 100x100+0+0 rose: \( rose: -set page +50+50 -negate \) rose_03.gif

Tried these merely for practice, hence no real-world use/scenario involved. Would greatly appreciate if someone could hopefully describe why these work the way they do. Or, point me to any documentation that describes this behaviour.

Used Firefox 61 to view output images. Running Arch Linux.

Thank you!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Offset behaviour with -page, -set page

Post by snibgo »

For v7, I suggest you always use "magick", not "convert" or "magick convert".

When writing images to GIF, IM processes offset metadata. So to understand what is happening, I suggest you also write to "info:"

Code: Select all

magick -delay 100 -page 100x100+0+0 ( rose: -set page +50+50 ) rose: +write info: r0.gif
rose:[0] PNM 70x46 100x100+50+50 8-bit sRGB 0.000u 0:00.000
rose:[1] PNM 70x46 100x100+0+0 8-bit sRGB 0.000u 0:00.016

magick -delay 100 -page 100x100+0+0 rose: ( rose: -set page +50+50 ) +write info: r1.gif
rose:[0] PNM 70x46 100x100+0+0 8-bit sRGB 0.016u 0:00.015
rose:[1] PNM 70x46 100x100+50+50 8-bit sRGB 0.016u 0:00.031

magick -delay 100 -page 100x100+0+0 rose: -negate ( rose: -set page +50+50 ) +write info: r2.gif
rose:[0] PNM 70x46 100x100+0+0 8-bit sRGB 0.000u 0:00.000
rose:[1] PNM 70x46 100x100+50+50 8-bit sRGB 0.000u 0:00.015

magick -delay 100 -page 100x100+0+0 rose: ( rose: -set page +50+50 -negate ) +write info: r3.gif
rose:[0] PNM 70x46 100x100+0+0 8-bit sRGB 0.016u 0:00.015
rose:[1] PNM 70x46 100x100+50+50 8-bit sRGB 0.016u 0:00.015
f:\web\im>
The text "info:" seems as expected.

You might want "-layers trim-bounds" before writing each gif.

Does that answer the question?
snibgo's IM pages: im.snibgo.com
codelad
Posts: 3
Joined: 2018-08-30T01:29:56-07:00
Authentication code: 1152

Re: Offset behaviour with -page, -set page

Post by codelad »

Thank you! Substituting 'magick' for 'convert' clears this up neatly, and also several more conversions including this one with '-repage' that had me confused:

magick -delay 100 -page 100x100+50+50 rose: -resize '200%' -repage 0x0+10+10 +write rose_00.gif info:
convert -delay 100 -page 100x100+50+50 rose: -resize '200%' -repage 0x0+10+10 +write rose_01.gif info:

Am just about starting with IM. Is there some place where magick vs convert differences are documented? If I recall right, the command-line documentation appeared to use 'magick convert' in examples (apparently targeting pre-v7 releases).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Offset behaviour with -page, -set page

Post by snibgo »

The v7 porting guide is http://www.imagemagick.org/script/porting.php

Most of the official documentation, and my own unofficial documentation, was written for v6. However, most of it should work when you use "magick" instead of "convert". The porting guide should tell you what needs changing.

However, many examples scattered around the web use very old syntax, such as operating on images before reading them, which is deprecated in v7.
snibgo's IM pages: im.snibgo.com
codelad
Posts: 3
Joined: 2018-08-30T01:29:56-07:00
Authentication code: 1152

Re: Offset behaviour with -page, -set page

Post by codelad »

Thank you. Somehow overlooked the porting guide earlier. Just what I needed.

After reading up some more, the v7 "magick" command largely appears to work predictably. And of the several other quirks I've come across, nearly all of them appear to be down to using "convert" in v7.

Have also noticed v6 still being recommended, but will stick to v7 (and "magick") till I run into something drastic.
Post Reply