Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate operator: inverse range parameter not working for IM7 #3113

Closed
piridium opened this issue Jan 12, 2021 · 3 comments
Closed

duplicate operator: inverse range parameter not working for IM7 #3113

piridium opened this issue Jan 12, 2021 · 3 comments

Comments

@piridium
Copy link

piridium commented Jan 12, 2021

Prerequisites

[ x ] I have written a descriptive issue title
[ x ] I have verified that I am using the latest version of ImageMagick
[ x ] I have searched open and closed issues to ensure it has not already been reported

Description

According to the legacy docs (https://legacy.imagemagick.org/Usage/anim_mods/#patrol), a patrol-cycle style animation is created by reversing the range parameter of the duplicate operator. However, this does not work in ImageMagick 7.

Steps to Reproduce

For a patrol-cycle style animation, we want to append all the frames in reverse except for the first and the last frame.
While appending the frames in forward order works as expected:
magick xc:#000 xc:#001 xc:#002 xc:#003 xc:#004 -duplicate 1,1--2 info:
Frames 0, 1, 2, 3 and 4 are followed by 1, 2 and 3:

xc:#000[0] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#001[1] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#002[2] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#003[3] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#004[4] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#001[5] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#002[6] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#003[7] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000

Reversing the range parameter...
magick xc:#000 xc:#001 xc:#002 xc:#003 xc:#004 -duplicate 1,-2-1 info:
... we would expect to see frames 0, 1, 2, 3 and 4 followed by 3, 2 and 1, but instead we get no change:

xc:#000[0] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#001[1] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#002[2] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#003[3] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000
xc:#004[4] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.000

There is a discussion here. Thanks @GeeMack for your help!

Proposed solution

Depending on the intended behavior of "-duplicate" and "-clone" either fix the inverse range method or update the docs with the workaround suggested by @GeeMack.

System Configuration

  • ImageMagick version: ImageMagick 7.0.10-57 Q16 x86_64
  • Environment (Operating system, version and so on): macOS 10.14.6
  • Additional information: @GeeMack also tested with ImageMagick 7.0.10-56 Q16 x64 on Windows 10
@snibgo
Copy link

snibgo commented Jan 12, 2021

The example shown works fine with IM v7.0.8-64:

f:\web\im>%IMG7%magick xc:#000 xc:#001 xc:#002 xc:#003 xc:#004 -duplicate 1,-2-1
 info:
xc:#000[0] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.011
xc:#001[1] XC 1x1 1x1+0+0 16-bit sRGB 0.031u 0:00.021
xc:#002[2] XC 1x1 1x1+0+0 16-bit sRGB 0.031u 0:00.030
xc:#003[3] XC 1x1 1x1+0+0 16-bit sRGB 0.031u 0:00.039
xc:#004[4] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.047
xc:#003[5] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.056
xc:#002[6] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.067
xc:#001[7] XC 1x1 1x1+0+0 16-bit sRGB 0.031u 0:00.077

But it fails with v7.0.10-45:

f:\web\im>%IMG701010%magick xc:#000 xc:#001 xc:#002 xc:#003 xc:#004 -duplicate 1,-2-1 info:
xc:#000[0] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.123
xc:#001[1] XC 1x1 1x1+0+0 16-bit sRGB 0.000u 0:00.157
xc:#002[2] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.165
xc:#003[3] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.174
xc:#004[4] XC 1x1 1x1+0+0 16-bit sRGB 0.016u 0:00.183

So it is a bug introduced between these versions.

urban-warrior pushed a commit to ImageMagick/ImageMagick6 that referenced this issue Jan 14, 2021
@urban-warrior
Copy link
Member

Thanks for the problem report. We can reproduce it and will have a patch to fix it in the GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

@piridium
Copy link
Author

I confirm that 7.0.10-58 fixes the bug. Thanks @urban-warrior for your great work!

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Jan 20, 2021
https://build.opensuse.org/request/show/864042
by user pgajdos + dimstar_suse
- update to 7.0.10.58:
  * identify the convex hull and minimum bounding box attributes of an image
    with the -define identify:convex-hull=true define.
  * set the quality to 100 to produce lossless HEIC images (reference
    ImageMagick/ImageMagick#3116).
  * properly identify SVG images (reference
    ImageMagick/ImageMagick#3117).
  * duplicate operator: inverse range parameter working again (reference
    ImageMagick/ImageMagick#3113).
  * Fix rounding error for CSS colors on i686 (reference
    https://tracker.debian.org/pkg/imagemagick).
  * additional checks to prevent integer overflow.
  * Fix rounding error for CSS colors (reference
    ImageMagick/ImageMagick6#129). (forwarded
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 25, 2021
2021-01-16  7.0.10-58  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-58 GIT revision 18277:8876652f5:20210116

2021-01-11  7.0.10-58  <quetzlzacatenango@image...>
  * identify the convex hull and minimum bounding box attributes of an image
    with the -define identify:convex-hull=true define.
  * set the quality to 100 to produce lossless HEIC images (reference
    ImageMagick/ImageMagick#3116).
  * properly identify SVG images (reference
    ImageMagick/ImageMagick#3117).
  * duplicate operator: inverse range parameter working again (reference
    ImageMagick/ImageMagick#3113).
  * Fix rounding error for CSS colors on i686 (reference
    https://tracker.debian.org/pkg/imagemagick).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants