Repository navigation
3.18.0
·
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 ofResizeModesandSVGScaleModes(3.17.0 gave them the old
values). The old values ('RESIZE_BILINEAR',1-3, still the values of the deprecatedImage.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), likeImage.decode()does (it already did for JPEG XLs).applyOrientation: falsekeeps the stored
frames. Still PNGs decoded byAnimation.decode()are rotated as well now.
New
Animation.decode()takesapplyOrientation,toneMappingandgainMaplikeImage.decode(): JPEG XL
animations can be tone mapped with'clamp', and theirjhgmgain map is read into thegainMapof every frame.resize({ width })andresize({ height })on images, frames and animations: the missing side keeps the aspect
ratio,resize({ width: 256, mode: 'bicubic' }).image.coordinates()yields[x, y]andimage.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.
layoutisTextLayoutOptionsor aTextLayout:Image.renderText('Hi', { font, size: 32, layout: { maxWidth: 400 } }).Infinityas the loop count of animations that loop forever (new Animation(frames, { loopCount: Infinity }),
and the encoders'). Animations that loop forever still have-1as theirloopCount(also the decoded ones).Animation.webpEncoder(),gifEncoder()andapngEncoder()take the options ofencodeWebP(),encodeGIF()and
encodeAPNG(), plusloopCount: the options are documented once.trim({ color, tolerance })andcolorToAlpha({ 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/coverwith amodeargument (useResizeOptions),Frameconstructor andFrame.from()with duration and offsets (useFrameOptions),Animationconstructor withloopCount(useAnimationOptions),Animation.decode(input, onlyExtractFirstFrame),Animation.resize(width, height, mode),Animation.encodeGIF(quality)andencodeAPNG(compression),encodePNG(compression, metadata)andencodePNG(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(andImage.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)) anditerateWithColors(): usecoordinates()and
pixels(). Removed in 4.0. Image.renderText(font, size, text, ...): userenderText(text, { font, size, ... }). Removed in 4.0, as is the
swapped use ofhorizontalAlignandverticalAlignvalues ofTextLayout.-1as a loop count, useInfinity. Removed in 4.0, when animations that loop forever haveInfinity.AnimationEncoderOptions,WebPAnimationEncoderOptions,GIFAnimationEncoderOptionsand
APNGAnimationEncoderOptions: they are the same asAnimationEncodeOptions,WebPAnimationEncodeOptions,
GIFEncodeOptionsandAPNGEncodeOptionswithloopCount, which are all the types there are in 4.0.encode(): useencodePNG(), which takes the same arguments. Removed in 4.0.cropCircle(max, feathering)and themaxoption: usecropCircle({ 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.