Skip to content

Add optional constructorOptions parameter to Sharp::run() - #3

Merged
kiatng merged 2 commits into
mainfrom
copilot/add-optional-run-parameter
Jan 11, 2026
Merged

Add optional constructorOptions parameter to Sharp::run()#3
kiatng merged 2 commits into
mainfrom
copilot/add-optional-run-parameter

Conversation

Copilot AI commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Adds support for Sharp constructor options (e.g., density, failOn, limitInputPixels) as an optional third parameter to Sharp::run().

Changes

  • src/Sharp.php: Add optional $constructorOptions = [] parameter; pass to sharp.js only when non-empty
  • src/sharp.js: Parse and pass constructor options to Sharp constructor
  • README.md: Document new parameter with example
  • tests/Unit/SharpTest.php: Add test for density option

Usage

Sharp::run(
    [
        'input' => ['is_raw' => false, 'data' => $svgPath],
        'output' => ['is_raw' => false, 'file' => $pngPath],
    ],
    ['resize' => ['width' => 300, 'height' => 200]],
    ['density' => 300] // Constructor options
);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/fM72pZ /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/fM72pZ /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/fM72pZ /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/fM72pZ /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/fM72pZ /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/fM72pZ /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/SrMz2A /usr/bin/composer install --no-interaction --prefer-dist (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Is it better to add an optional param constructorOptions to the run method?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai

coderabbitai Bot commented Jan 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: kiatng <1106470+kiatng@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optional constructorOptions parameter to run method Add optional constructorOptions parameter to Sharp::run() Jan 5, 2026
Copilot AI requested a review from kiatng January 5, 2026 05:20
@kiatng
kiatng marked this pull request as ready for review January 5, 2026 05:29

@kiatng kiatng left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fluxxus

fluxxus commented Jan 10, 2026

Copy link
Copy Markdown

i

Same here. I see no issues with adding a third parameter. Better than unnecessary nesting IMO. Feel free to merge this one if you ask me. Thx

@kiatng
kiatng merged commit 63386e9 into main Jan 11, 2026
1 check passed
@kiatng
kiatng deleted the copilot/add-optional-run-parameter branch January 11, 2026 04:19
@kiatng kiatng added the enhancement New feature or request label Jan 11, 2026
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.

3 participants