Repository navigation
Image 0.73.0
This is the changelog for Image version 0.73.0 released on October 28th, 2026. For older changelogs please consult the release tag on GitHub
A large release on the way to 1.0, with 30 breaking changes in five areas:
-
One opacity vocabulary —
opacityis now the value a caller sets andalphathe band it is written to, sotransparencyis gone andImage.opacity/2is deprecated in favour ofImage.multiply_alpha/2. -
Alpha and colour scale to the interpretation — 16-bit and scRGB images were given 8-bit values, leaving them 0.4% opaque or out of range, which corrects
Image.add_alpha/2,Image.Pixel.to_pixel/3,Image.fade/2andImage.drop_shadow/2. -
Errors instead of exceptions — around twenty functions return
{:error, %Image.Error{}}where they raisedFunctionClauseError,ArithmeticErroror aNimbleOptionserror, andImage.Pixelreturns anImage.Erroron every path. -
Image.compare/3works beyond three-band sRGB — it failed outright on a greyscale image, and its default:aemetric counted only the first band, so images differing in any other compared as identical. -
Image.reduce_colors/2keeps its input's type — it returns{:u, 8}rather than{:f, 32}, and the colorspace it was given rather than always sRGB.
It also adds Image.copy_memory/1, for the pipelines that need to be consumed more than once.
Many many thanks to @hlindset who took on the monumental task of significantly improving the way in which standard vocabulary is used, validated and applied. Thank you very much Håvard.
Added
-
Adds
:backgroundand:interpolateoptions to themapim-based transformations —Image.ripple/2,Image.to_polar_coordinates/2andImage.distort/4gain both,Image.to_rectangular_coordinates/2,Image.warp_perspective/4,Image.straighten_perspective/3andImage.map/3gain:interpolate, andImage.distort/4also gains:extend_mode(:backgroundor:copy).:interpolatedefaults to:bilinearexcept forImage.distort/4, which keeps its:bicubicdefault. (#216) -
Adds
Image.chroma_color!/1as a companion toImage.chroma_color/1. (#219) -
Adds
Image.Pixel.strip_alpha/2which returns a resolved pixel without its alpha component. It consolidates the truncation thatImage.flatten/2,Image.chroma_mask/2,Image.Options.TrimandImage.Options.Writeeach did separately before. (#222) -
Adds
Image.Pixel.put_alpha/3andImage.Pixel.put_alpha!/3, which return a pixel with its alpha component set to a given opacity, scaled to the image's alpha band. The pixel is returned unchanged when the image has no alpha band. (#231) -
Adds
Image.Pixel.opacity_fraction/1andImage.Pixel.opacity_fraction!/1, which return an opacity as a fraction of full opacity. UnlikeImage.Pixel.alpha_for/2the result belongs to no particular image. (#231) -
Adds
Image.Pixel.alpha_for/2andImage.Pixel.alpha_for!/2, which scale an opacity to the alpha band of a given image, whose range depends on the interpretation. (#231) -
Adds
Image.multiply_alpha/2andImage.multiply_alpha!/2, which multiply an image's alpha band by a0.0..1.0factor. They replaceImage.opacity/2, which is deprecated and delegates to them. -
Adds
Image.copy_memory/1andImage.copy_memory!/1, which return an image guaranteed to be resident in memory. A thumbnail taken from a pathname streams from the file and can only be consumed once, so a pipeline that runs over one more than once needs this. (#175) -
Documents the pipeline depth limit in the Performance guide. A loop that accumulates more than roughly 150 pending operations exhausts the stack of the thread libvips is evaluated on and takes the VM down; flattening every 25 to 50 operations with
Image.copy_memory/1avoids it. (#192) -
Adds
text_fill_color: :markuptoImage.Text.text/2andImage.Text.simple_text/2, which takes the color of each part of the text from the Pango markup so one string can render in more than one color. Text with no color set in the markup renders black. (#233)
Changed
-
Image.Pixel.to_pixel/3now applies the:opacityoption to a color given as a list of numbers. It was previously ignored for those, soto_pixel(image, [255, 0, 0, 255], opacity: 0.5)returned a fully opaque pixel. (#231) -
The
:opacityoptions ofImage.Shapeand the:background_fill_opacity/:background_stroke_opacityoptions ofImage.Text.text/2accept anyt:Image.Pixel.opacity/0rather than only a float, so every function taking an opacity now accepts the same values. (#231) -
Breaking: The
:opacityoption ofImage.drop_shadow/2accepts anyt:Image.Pixel.opacity/0rather than any number in0.0..1.0. Only1changes meaning — it was fully opaque and is now 8-bit notation for1/255, so use1.0instead;0remains fully transparent. (#231) -
Breaking:
Image.Pixelreturns anImage.Erroron every error path, which reaches every function that resolves a color, including the:backgroundoptions. An unsupported interpretation was a bare string and is nowreason: :unsupported_interpretation; an invalid color was theColorlibrary's own exception and is nowreason: :invalid_colorwith the color invalue. (#231) -
Breaking: An invalid opacity reports
reason: :invalid_opacityinstead of:invalid_transparency. (#231) -
Breaking:
Image.Pixel.to_pixel/3returns linear light values for an:scrgbimage, which affects every function that resolves a color against one. It previously returned gamma encoded sRGB, so a color drawn onto an scRGB image came out too bright and desaturated. (#230) -
Breaking:
Image.Pixel.to_pixel/3returns relative luminance (CIEY) for a single band:scrgbimage. It previously returned a0..255integer, so:whiteresolved to255rather than1.0. (#230) -
Breaking:
Image.Pixel.to_pixel/3no longer rounds a float:opacityto a byte before scaling it, soopacity: 0.5resolves to0.5on an:scrgbimage and32768on a 16-bit image where both previously went via128and came out as0.50196and32896. Interpretations with an 8-bit alpha band are unaffected, including Lab and LCH. (#231) -
Image.add_alpha/2accepts a float in0.0..1.0as well as the integer and atom forms it already took. An integer is a fraction of 255, so a float is the only way to add exactly half opacity to a 16-bit or:scrgbimage. (#231) -
Image.add_alpha/2returns{:error, %Image.Error{reason: :invalid_opacity}}for an invalid opacity, where it previously raisedFunctionClauseError. (#231) -
Breaking:
Image.add_alpha/2scales the alpha band it adds to the image's interpretation, so:opaqueresolves to65535on a 16-bit image and1.0on an:scrgbimage where it previously wrote255into both, leaving 16-bit images 0.4% opaque and scRGB images out of range. An integer is now a fraction of255, so128means the same opacity everywhere; interpretations with an 8-bit alpha band are unaffected, including Lab and LCH. (#231) -
Breaking:
Image.average/1andImage.chroma_color/1now return{:ok, [number()]} | {:error, Image.Error.t()}instead of a bare list on success. The previous success type was documented asPixel.t()but was always a list of numbers. (#219) -
Breaking:
Image.warp_perspective/4andImage.straighten_perspective/3now preserve image alpha instead of always flattening, so the band count and pixels of the result may change; images without alpha are unaffected. An omitted:backgrounddefers to libvips' fill rather than defaulting to:black, matching the other background-taking functions. (#216) -
Breaking:
Image.map/3now fills exposed pixels of an alpha image with transparent black rather than opaque black, matching the:backgrounddefault of the othermapimtransformations. (#216) -
Breaking:
Image.to_rectangular_coordinates/2now clamps boundary samples to the source edge color instead of blending towards a zero fill. (#216) -
Breaking: The
Image.Options.*validators accept keyword lists only, so passing a pre-validated map now raisesFunctionClauseErrorandmap()is removed from 22 option union types. This affectsImage.blur/2,Image.feather/2,Image.sharpen/2,Image.modulate/2,Image.vignette/2,Image.embed/4,Image.chroma_mask/2,Image.chroma_key/2,Image.trim/2,Image.find_trim/2,Image.vibrance/3,Image.rotate/3,Image.affine/3,Image.shear/4,Image.resize/3,Image.thumbnail/3, theImage.Drawfunctions and all their!variants; hoist the color resolution instead if the validation cost matters in a tight loop. (#220) -
Breaking:
Image.from_binary/2returns{:error, %Image.Error{}}rather than{:error, binary}, andImage.write/3to aPlug.Connreturns%Image.Error{reason: :closed}rather than{:error, :closed}. Every error path inImage.open/2andImage.write/3now returns a structuredImage.Errorwith:operationset. (#218) -
Breaking:
Image.Error.exception(reason: :enoent, path: path)now producesImage.Error.wrap/2's message, and a{atom, value}reason built throughImage.Error.wrap/2gains the"Image error: "prefix. (#218) -
Breaking:
Image.drop_shadow/2returns{:error, %Image.Error{}}for a non-numeric:sigmainstead of raisingArithmeticError, and its:opacityand:sigmaerrors now carryreason: :invalid_optionwithvalueset to{:opacity, value}or{:sigma, value}.:dx,:dyand unknown options remain unvalidated, pending a move to anImage.Options.DropShadowmodule. (#221) -
Breaking:
Image.chroma_mask/2,Image.chroma_key/2,Image.replace_color/2and their!variants now return{:error, %Image.Error{reason: :invalid_option}}when options from both masking strategies are supplied, or when only one of:greater_thanand:less_thanis supplied. The two strategies were always documented as mutually exclusive, but nothing enforced it: the color range strategy won and:colorand:thresholdwere silently discarded, and a lone bound was discarded and replaced by auto chroma detection with the default threshold. (#224) -
Breaking:
Image.Scholar.k_means/2returns{:ok, model}instead of a bare fittedScholar.Cluster.KMeanson success, matchingImage.Scholar.unique_colors/1and the rest of the library. (#227) -
Breaking:
Image.k_means/2andImage.reduce_colors/2return{:error, %Image.Error{reason: :invalid_option}}for an invalid or unknown option instead of raisingNimbleOptions.ValidationError, and the!variants raiseImage.Errorrather than the NimbleOptions exception.operationis set tok_meansorreduce_colors, andvalueis{key, value}for an invalid value or the list of keys for unknown options. (#227) -
Breaking:
Image.reduce_colors/2returns{:u, 8}instead of{:f, 32}, rounding the result into the band format it clustered where k-means produced a float image that nothing cast back. libvips truncated those float values when casting on save, so output values can change by up to 1 per channel. (#229) -
Breaking:
Image.reduce_colors/2returns the image in the colorspace it was given. A:cmykimage returns four bands and a greyscale image returns one, where previously every image came back as 3-band:srgb. (#229) -
Image.reduce_colors/2clamps:colorsto the number of unique colors in the image. Previously a:colorsgreater than the image's pixel count failed. (#229) -
Image.affine/3andImage.rotate/3now premultiply alpha explicitly only when the background is non-opaque, since libvips handles the other cases itself.Image.shear/4andImage.translate/4inherit this. (#217) -
Image.multiply_alpha/2returns{:error, %Image.Error{reason: :invalid_factor}}for a factor outside0.0..1.0or of the wrong type, whereImage.opacity/2previously raisedFunctionClauseError. The!variant raisesImage.Error. -
Deprecates
Image.opacity/2andImage.opacity!/2in favour ofImage.multiply_alpha/2andImage.multiply_alpha!/2, whose argument is a multiplier rather than at:Image.Pixel.opacity/0. The old names still work and delegate. -
Image.brightness/2,Image.saturation/2,Image.vibrance/3,Image.dilate/2,Image.erode/2,Image.dhash/2,Image.pixelate/2,Image.rotate/3,Image.shear/4,Image.translate/4,Image.meme/3,Image.from_binary/2,Image.from_svg/2andImage.join_bands/1return{:error, %Image.Error{}}for an invalid argument instead of raisingFunctionClauseError. Each reason is an:invalid_<argument>atom, and ten!variants that duplicated their guard now raiseImage.Erroras intended rather thanFunctionClauseError. -
Image.posterize/2,Image.sepia/2,Image.gamma/2andImage.set_orientation/2return{:error, %Image.Error{}}for an invalid argument, where they previously raisedFunctionClauseErrordespite each declaring{:error, error()}in its spec. The reasons are:invalid_levels,:invalid_strength,:invalid_exponentand:invalid_orientation, and the!variants raiseImage.Error. -
Widens the specs of
Image.multiply_alpha/2,Image.sepia/2andImage.gamma/2fromfloat()tonumber()andImage.set_orientation/2from1..8tointeger(), matching the values their guards have always accepted and their new error clauses reject.
Fixed
-
Fix
Image.warp_perspective/4,Image.straighten_perspective/3andImage.map/3reproducing non-opaque backgrounds incorrectly. (#216) -
Fix
Image.chroma_mask/2andImage.find_trim/2using an error tuple as a pixel when an:autocolor lookup failed. They now propagate the error. (#219) -
Fix
Image.open!/2putting the whole image into the error's:pathand interpolating it into:message. (#218) -
Fix the specs for
Image.Math.cos/1andImage.Math.sin/1, which omitted{:error, Image.error()}, and for eight math operators, which omitted theVimage.t()they already accepted. All@dialyzeropt-outs and the.dialyzer_ignore_warningsfile are removed. (#221) -
Fix the
:greater_thanand:less_thandocumentation forImage.chroma_mask/2,Image.chroma_key/2andImage.replace_color/2, which described the bounds the wrong way round in all six places they appeared. The mask covers the range between the two, so:greater_thanis the lower bound and:less_thanthe upper. (#224) -
Fix
Image.reduce_colors/2silently producing wrong output above 256 colors. A cast to{:u, 8}wrapped every color index above 255 back around (256 became 0, 257 became 1, and so on), so those pixels were painted with the color reached by the wraparound. (#229) -
Fix
Image.reduce_colors/2raising instead of returning an error tuple, both for theArgumentErrorthatScholar.Cluster.KMeans.fit/2raises for checks it makes outside its option schema, and for theArithmeticErrorit raises when given a single sample. (#229) -
Fix
Image.reduce_colors/2raising when the image could not be converted to a tensor. (#229) -
Fix
Image.multiply_alpha/2(formerlyImage.opacity/2) andImage.fade/2casting the scaled alpha band toucharunconditionally, which saturated a 16-bit alpha to255and truncated a float one to0. A half-opacity call returned a fully transparent scRGB image and a 0.4%-opacity 16-bit one, andImage.fade/2lost its gradient on both. -
Fix
Image.compare/3failing withcomposite2: images do not have same numbers of bandsfor any image that is not three-band sRGB. The composed difference is one band wider than the base, and libvips only infers the extra alpha band for sRGB band counts, so a greyscale comparison never composited. (#232) -
Fix
Image.compare/3resolving:difference_coloragainst the image before flattening it, so a two-band greyscale image resolved:redto a two-element pixel that no longer matched the one-band difference. (#232) -
Breaking: Fix the
:rmsemetric ofImage.compare/3, which scales the error by the range of the band format and so returned about1.0e-9for a float image and raisedCaseClauseErrorfor a signed one. Float formats now return{:error, %Image.Error{reason: :unsupported_metric}}and signed formats are scaled like unsigned ones. (#232) -
Breaking: Fix the
:aemetric ofImage.compare/3, the default, counting a pixel as different only when its first band differed, so two images differing solely in the blue band compared as an exact match. Any band differing now counts. (#232) -
Fix
Image.compare/3highlighting a difference in the wrong colour when it was confined to some bands: the difference was a per-band condition, so a blue-only change came out dark grey and a Lab one lost itsaandbbands. The colour is now applied wherever the pixel differs, with the mask as the overlay's alpha. (#232) -
Fix
Image.compare/3under-weighting the difference mask for:laband:lchimages. Each band's difference is now a fraction of that band's own range before the largest is taken, soLis measured against0..100,aandbagainst±128and LCH'shagainst0..360, rather than every band against one range. (#232) -
Fix
Image.compare/3inverting its difference mask for a CMYK image, where a zero difference is no ink and so converted to white and to full opacity, blanking the background. The mask is now the largest absolute difference across the bands, which is zero for an unchanged pixel in every interpretation. (#232) -
Fix
Image.compare/3writing an 8-bit difference mask into the alpha band of a 16-bit image, which left the highlight at 0.4% opacity and invisible. (#232) -
Fix
Image.join_bands/1raisingArgumentErrorfor a list holding anything other than an image. Its guard checked only that the argument was a list, so the contents reachedvips_bandjoinunvalidated. -
Fix
Image.resize/3's guard, which testedscale >= 0withoutis_number/1, so a string, atom or list sorted above every number, passed the guard and raisedArgumentErrorfrom libvips. It now returns{:error, %Image.Error{reason: :invalid_scale}}. -
Fix
Image.drop_shadow/2building its shadow and canvas as 8-bit sRGB whatever the source interpretation, so a 16-bit shadow saturated to fully opaque, an scRGB one returned an alpha of127in a0.0..1.0band, and a CMYK one lost a band. It now composites in the source's own format and returns the interpretation, band format and band count it was given.
Removed
-
Breaking: Removes
Image.Pixel.transparency/1,Image.Pixel.max_opacity/0andImage.Pixel.min_opacity/0. UseImage.Pixel.alpha_for/2for a value to write into an image's alpha band, orImage.Pixel.opacity_fraction/1for the opacity itself. (#231) -
Breaking: Removes the
t:Image.transparency/0andt:Image.Pixel.transparency/0types. Uset:Image.Pixel.opacity/0, which is now the only opacity type. (#231) -
Breaking: Removes the
:alphaoption ofImage.Pixel.to_pixel/3and the{color, alpha: alpha}background form. Use:opacityand{color, opacity: opacity}, which are the same options under new names. (#231) -
Breaking: Removes
:noneas an opacity, though not as a color. Use:transparentinstead, which it was a synonym for. (#231) -
Breaking: Removes
Image.Options.WarpPerspective, replaced byImage.Options.Mapim. (#216) -
Breaking: Removes
Image.Options.Meme.validate_options/1andImage.Draw.maybe_add_alpha/2. (#220) -
Breaking: Removes the
Image.Errortuple constructors.raise Image.Error, {:enoent, path}andraise Image.Error, {message, path}now fall through to the catch-all clause. (#218) -
Breaking: Removes the
:sigmaand:min_amplitudeoptions fromImage.chroma_mask/2,Image.chroma_key/2andImage.replace_color/2. They were accepted and validated, but never read by any code path. (#224)