Skip to content

3.18.0

Choose a tag to compare

@matmen matmen released this 08 Nov 10:49
· 25 commits to master since this release
Immutable release. Only release title and notes can be modified.

3.18.0

Changes

  • Resize and SVG scale modes are lowercase names: 'nearest-neighbor', 'bilinear', 'bicubic', 'area' and
    'scale', 'width', 'height', also as the values of ResizeModes and SVGScaleModes (3.17.0 gave them the old
    values). The old values ('RESIZE_BILINEAR', 1-3, still the values of the deprecated Image.RESIZE_* and
    Image.SVG_MODE_*) keep working until 4.0: image.resize(256, 256, 'bicubic').

  • Animation.decode() applies the orientation of APNGs and animated WebPs (their eXIf and EXIF chunks, and XMP
    in PNGs), like Image.decode() does (it already did for JPEG XLs). applyOrientation: false keeps the stored
    frames. Still PNGs decoded by Animation.decode() are rotated as well now.

New

  • Animation.decode() takes applyOrientation, toneMapping and gainMap like Image.decode(): JPEG XL
    animations can be tone mapped with 'clamp', and their jhgm gain map is read into the gainMap of every frame.
  • resize({ width }) and resize({ height }) on images, frames and animations: the missing side keeps the aspect
    ratio, resize({ width: 256, mode: 'bicubic' }).
  • image.coordinates() yields [x, y] and image.pixels() yields [x, y, color] for every pixel, row by row.
  • cropCircle({ size: 'contain' | 'cover' }): 'contain' (the default, as before) keeps the circle inside the image.
  • Image.renderText(text, { font, size, color, layout, ...style }): the text first, everything else in the options.
    layout is TextLayoutOptions or a TextLayout: Image.renderText('Hi', { font, size: 32, layout: { maxWidth: 400 } }).
  • Infinity as the loop count of animations that loop forever (new Animation(frames, { loopCount: Infinity }),
    and the encoders'). Animations that loop forever still have -1 as their loopCount (also the decoded ones).
  • Animation.webpEncoder(), gifEncoder() and apngEncoder() take the options of encodeWebP(), encodeGIF() and
    encodeAPNG(), plus loopCount: the options are documented once.
  • trim({ color, tolerance }) and colorToAlpha({ color, transparencyThreshold, opacityThreshold }): the color goes into the options, like the other options. GainMap.encode({ quality }) likewise.

Deprecated

  • Positional optional arguments, the options take the same values: trim(color, options), colorToAlpha(color, options), GainMap.encode(quality), resize/scale/contain/fit/cover with a mode argument (use ResizeOptions), Frame constructor and Frame.from() with duration and offsets (use FrameOptions), Animation constructor with loopCount (use AnimationOptions), Animation.decode(input, onlyExtractFirstFrame), Animation.resize(width, height, mode), Animation.encodeGIF(quality) and encodeAPNG(compression), encodePNG(compression, metadata) and encodePNG(metadata), encodeJPEG(quality), renderSVG(svg, size, mode), composite(source, x, y, options), rotate(angle, resize), sharpen(amount, radius), roundCorners(radius), fisheye(strength), dominantColor(ignoreBlack, ignoreWhite, threshold). All of them still work until 4.0.
  • The numeric frame disposal ids (0-3): use the names ('any', 'keep', 'previous', 'background'). Removed in 4.0.
  • ResizeModes.AUTO (and Image.RESIZE_AUTO, Frame.RESIZE_AUTO): pass only the width or the height instead.
    Removed in 4.0.
  • Iterating over an image (for (const [x, y] of image)) and iterateWithColors(): use coordinates() and
    pixels(). Removed in 4.0.
  • Image.renderText(font, size, text, ...): use renderText(text, { font, size, ... }). Removed in 4.0, as is the
    swapped use of horizontalAlign and verticalAlign values of TextLayout.
  • -1 as a loop count, use Infinity. Removed in 4.0, when animations that loop forever have Infinity.
  • AnimationEncoderOptions, WebPAnimationEncoderOptions, GIFAnimationEncoderOptions and
    APNGAnimationEncoderOptions: they are the same as AnimationEncodeOptions, WebPAnimationEncodeOptions,
    GIFEncodeOptions and APNGEncodeOptions with loopCount, which are all the types there are in 4.0.
  • encode(): use encodePNG(), which takes the same arguments. Removed in 4.0.
  • cropCircle(max, feathering) and the max option: use cropCircle({ size: 'contain' | 'cover' }). Removed in 4.0.

Documentation

  • Deprecated overloads are tagged in the reference as well: a Deprecated label sits in front of each one, with the replacement named below it, also for methods that have other overloads that aren't deprecated.