Skip to content

Options objects - #58

Merged
matmen merged 2 commits into
masterfrom
options-objects
Oct 16, 2026
Merged

matmen merged 2 commits into
masterfrom
options-objects

Conversation

@matmen

@matmen matmen commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Every method with optional arguments now also takes them as an options object, so options can be left out or added without counting positions:

image.resize(100, 100, {mode: Image.RESIZE_BICUBIC});
image.composite(logo, {x: 10, y: 10, opacity: 0.5});
Image.renderText(font, 32, 'Hi', {color: 0xff0000ff, strokeWidth: 2});
new Frame(10, 10, {duration: 50});
animation.encodeGIF({quality: 80});
image.encodeJPEG({quality: 80, metadata: {author: 'me'}});

Covered: the resize methods, opacity/red/green/blue/lightness/saturation, composite, sharpen, roundCorners, fisheye, every encoder, renderSVG, renderText, Frame and Frame.from, Animation, Animation.decode() and decode() (onlyFirstFrame, applyOrientation).

  • The positional arguments keep working until 4.0.
  • encode() still takes metadata as its first argument, because metadata and the options don't share any keys.
  • The metadata arguments that the other encoders got earlier in 3.2.0 (unreleased) only exist as the metadata option, so no new positional arguments are released.

matmen and others added 2 commits October 15, 2026 18:59
Every method with optional arguments takes them as an options object
too: the resize methods ({mode}), opacity/red/green/blue/lightness/
saturation ({absolute}), composite ({x, y, opacity, mode}), sharpen
({amount, radius}), the encoders ({compression|quality, metadata}),
renderSVG ({size, mode}), renderText ({color, layout, ...style}),
Frame and Frame.from ({duration, xOffset, yOffset, disposalMode}),
Animation ({loopCount}), Animation.decode() and decode()
({onlyFirstFrame}, decode() also {applyOrientation}). The positional
arguments keep working.

encode() still takes metadata as its first argument: metadata and the
options have no key in common. The metadata arguments the other
encoders got for 3.2.0 (unreleased) are options only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MLHc7GW46D6BmwtEM2khgr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MLHc7GW46D6BmwtEM2khgr
@matmen matmen added this to the v3.2.0 milestone Oct 16, 2026
@matmen matmen self-assigned this Oct 16, 2026
@matmen matmen added the enhancement New feature or request label Oct 16, 2026
@matmen
matmen merged commit 978b136 into master Oct 16, 2026
13 checks passed
@matmen
matmen deleted the options-objects branch October 16, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant