Imagemagick: Proposal: image option "gif:frames-limit"

Created on 21 Jun 2018  路  5Comments  路  Source: ImageMagick/ImageMagick

Description

Currency ImageMagick GIF coder can't complete processing GIF frames halfway.
There is a situation of giving up GIF decoding itself even if it can decode only one frame.

GIF animation can be intertframe-compressed with dispose method, ImageMagick expands all frames to RGB(A) array in the original spacial size, so memory usage tends to unintentionally expand compared to the original GIF file size.

  • adding image option "gif:frames-limit" to coders/gif.c

    • gif:frames-limit:0 => unlimit (as default)

    • gif:frames-limit:{n} => {n} is upper limit of number of frames

Steps to Reproduce

N/A

System Configuration

  • ImageMagick version: 7.0.8-2, 6.9.10-2
  • Environment (Operating system, version and so on): N/A
  • Additional information:

consideration

  • suitable naming? > "frames-limit"
  • alter itea

    • decode-frames-limit

    • max-frames

future suggestions

  • environment variable: MAGICK_FRAMES_LIMIT
  • policy domain resource: name="frames-limit"
  • option: -limit frames

However, it may be better to implement these items after applying frames limit options to some animation image formats at least.

All 5 comments

We have a global limit for this inside the security policy:

C# <policy domain="resource" name="list-length" value="128"/>

I wonder if we have a could also make something generic to limit the length of the list for all image formats with a define. Maybe @urban-warrior has some ideas on how we could implement this?

Oh. I see..
I drop my "future suggestions" env & policy.

However, the resource "list-length" limit does't save memory usage for GIF decode processing.

https://github.com/ImageMagick/ImageMagick/pull/1181
This PR will resolve it.

Thank you for your proposal and patch. However, ImageMagick can already limit the number of frames. For example:

convert 'image.gif[0-14]' null:

Sorry for taking your time, and thank you very much.

Thank you for letting me notice my misunderstanding.
GIF coder can complete processing GIF frames halfway.

I overlooked following code, relative to 'image.gif[0-14]'

* coders/gif.c
    if (image_info->number_scenes != 0)
      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
        break;

Thanks!

Was this page helpful?
0 / 5 - 0 ratings