imgix APIsRendering APIAnimationFrame Selection

Frame Selection

frame

Premium Feature

Frame Selection functionality is currently available for imgix customers on our Premium plans. If you’re interested in this feature, please contact our sales team to get more information on this feature.

Enables selection of a single frame or a range, to enable preview of the GIF file. Ranges can take three forms:

  • M-N: Selects frames M and N and all frames in between
  • M-: Selects frames from M through the end of the file
  • -N: Selects frames from 1–N

Single-Frame Outputs

Original
sandbox-demo
frame=1
sandbox-demo
frame=50&fm=jpg
sandbox-demo

Frame Range Outputs

frame=-40
sandbox-demo
frame=-20-60
sandbox-demo
frame=40-
sandbox-demo

In addition to extracting a portion of the animation, you can extract metadata from the image with the fm=json parameter and use it for further operations. For example, this is the metadata from the above cartoon:

{
  "GIF": {
    "DelayTime": 0.06,
    "UnclampedDelayTime": 0.06
  },
  "Depth": 8,
  "ColorModel": "RGB",
  "HasAlpha": true,
  "PixelHeight": 240,
  "PixelWidth": 320,
  "Output": {
    "Frames": 38
  },
  "ProfileName": "sRGB IEC61966-2.1"
}

The most meaningful fields for animated GIFs are PixelHeight, PixelWidth, and Frames. They can be used as inputs for further calculations and operations, such as maintaining or changing the aspect ratio across a catalog of images or extracting a thumbnail preview of part of the animation. See our JSON tutorial for more information about using metadata this way.