Skip to content

Add support for crop_aspect_ratio option#53

Merged
11bit merged 1 commit into
mainfrom
feat/crop-aspect-ratio
Jul 2, 2025
Merged

Add support for crop_aspect_ratio option#53
11bit merged 1 commit into
mainfrom
feat/crop-aspect-ratio

Conversation

@11bit
Copy link
Copy Markdown
Collaborator

@11bit 11bit commented Jul 2, 2025

Closes #49

@11bit 11bit force-pushed the feat/crop-aspect-ratio branch from c791342 to 2dc2d32 Compare July 2, 2025 06:37
@11bit 11bit requested a review from Copilot July 2, 2025 07:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for the crop_aspect_ratio option to allow specifying a fixed aspect ratio for crop areas.

  • Defines new types and interfaces for CropAspectRatio and its aliases (crop_ar, car)
  • Implements test and build functions with validation and URL segment generation
  • Updates utility (normalizeBoolean) to accept 0 and other boolean variants

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/optionsBasic/cropAspectRatio.test.ts Adds tests covering detection, error conditions, and builds
src/utils.ts Extends normalizeBoolean signature to accept 0
src/types/index.ts Imports new CropAspectRatioOptionsPartial into Options
src/types/cropAspectRatio.ts Defines CropAspectRatio and partial options interface
src/options/index.ts Exports new cropAspectRatio module
src/options/cropAspectRatio.ts Implements option handling (test, build)
Comments suppressed due to low confidence (4)

src/utils.ts:1

  • Consider adding a test case to verify that passing enlarge: 0 correctly serializes to "f", since 0 is now an accepted input.
export const normalizeBoolean = (value: 1 | 0 | string | boolean): string => {

tests/optionsBasic/cropAspectRatio.test.ts:94

  • Add a test for enlarge: 0 to ensure build({ crop_aspect_ratio: { aspect_ratio: X, enlarge: 0 } }) yields the expected ":f" suffix.
    });

src/options/cropAspectRatio.ts:18

  • The error always references crop_aspect_ratio even if the user passed crop_ar or car. Consider capturing the actual key name for clearer error messages.
  guardIsUndef(cropArOpts, "crop_aspect_ratio");

src/utils.ts:20

  • The generated error message uses "less then" which is grammatically incorrect. Update to "less than" in the getMinNumText implementation.
    );

@11bit 11bit merged commit 8734a71 into main Jul 2, 2025
1 check passed
@11bit 11bit deleted the feat/crop-aspect-ratio branch July 2, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage docs of imgproxy have been updated

2 participants