Skip to content

Conversation

@piyushryn
Copy link

@piyushryn piyushryn commented Jan 27, 2026

Adds

  • Features like trim , color-replace , border, sharpen, unsharpen mask to base image
  • and trim adjustment , border, sharpen & unsharpen mask to layers

@piyushryn piyushryn requested a review from Copilot January 27, 2026 11:21
Copy link

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

This PR adds image enhancement features to both base images and layers, including trim, color replace, border, and sharpen transformations.

Changes:

  • Added four new adjustment transformations for base images: Border, Trim, Color Replace, and Sharpen
  • Extended layer transformations with trim threshold, border, and sharpen capabilities
  • Enhanced ColorPickerField component to accept and apply fieldProps configuration

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/imagekit-editor-dev/src/schema/index.ts Added schema definitions for new transformations (border, trim, color-replace, sharpen) and updated layer transformation handling
packages/imagekit-editor-dev/src/components/sidebar/transformation-config-sidebar.tsx Added fieldProps prop to ColorPickerField component
packages/imagekit-editor-dev/src/components/common/ColorPickerField.tsx Updated to accept and spread fieldProps into the ColorPicker component

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
key: "ai",
name: "AI Transformations",
items: [{
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Inconsistent formatting: the opening bracket should be on a new line to match the formatting pattern used elsewhere in this array (see line 1578 and others).

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

overlayTransform.sharpen = values.sharpen
}
}
if ((values.borderWidth && typeof values.borderWidth === "number" && values.borderWidth > 0) && (values.borderColor && typeof values.borderColor === "string")) {
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Excessive nested parentheses reduce readability. Consider extracting conditions into named boolean variables or simplifying the expression structure.

Suggested change
if ((values.borderWidth && typeof values.borderWidth === "number" && values.borderWidth > 0) && (values.borderColor && typeof values.borderColor === "string")) {
const hasValidBorderWidth =
typeof values.borderWidth === "number" && values.borderWidth > 0
const hasValidBorderColor =
typeof values.borderColor === "string" && values.borderColor.length > 0
if (hasValidBorderWidth && hasValidBorderColor) {

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI commented Jan 27, 2026

@piyushryn I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you.

@piyushryn piyushryn changed the base branch from main to IK-2461/enhancements January 29, 2026 07:22
@piyushryn piyushryn requested a review from Copilot January 30, 2026 05:12
Copy link

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



export const optionalPositiveFloatNumberValidator = z.preprocess(
(val) => (val === "" || val === undefined || val === null) ? undefined : val,
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The preprocessor function returns undefined for empty strings, undefined, and null, but the validator chain already includes .optional(). This makes the undefined return redundant. Consider simplifying to just handle empty strings: (val) => (val === '') ? undefined : val

Suggested change
(val) => (val === "" || val === undefined || val === null) ? undefined : val,
(val) => (val === "" || val === null) ? undefined : val,

Copilot uses AI. Check for mistakes.
defaultTransformation: {},
schema: z
.object({
borderWidth: z.union([widthValidator, heightValidator]).optional(),
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

Using heightValidator for borderWidth is confusing. Consider creating a dedicated borderWidthValidator or using just widthValidator if the validation logic is identical.

Suggested change
borderWidth: z.union([widthValidator, heightValidator]).optional(),
borderWidth: widthValidator.optional(),

Copilot uses AI. Check for mistakes.
return false
},
{
message: "Border width and color are required",
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The error message states both width and color are required, but the schema makes both optional and the refine check passes if either is provided. The message should be 'At least one of border width or color is required' to match the validation logic.

Suggested change
message: "Border width and color are required",
message: "At least one of border width or color is required",

Copilot uses AI. Check for mistakes.
Comment on lines +1855 to +1858
unsharpenMaskRadius: z.coerce.number().positive({ message: "Should be a positive floating point number." }),
unsharpenMaskSigma: z.coerce.number().positive({ message: "Should be a positive floating point number." }),
unsharpenMaskAmount: z.coerce.number().positive({ message: "Should be a positive floating point number." }),
unsharpenMaskThreshold: z.coerce.number().positive({ message: "Should be a positive floating point number." }),
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

These four fields have identical validation logic. Consider extracting this as a reusable validator (similar to optionalPositiveFloatNumberValidator) to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
isTransformation: false,
transformationGroup: "imageLayer",
helpText:
"Toggle to unsharpen the overlay image to remove the edges and finer details within an image.",
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The help text incorrectly describes unsharpen mask as removing edges and details, when it actually enhances them. Based on the description at line 1850, it should read: 'Toggle to apply unsharpen mask to the overlay image to enhance edge contrast and make details appear clearer.'

Suggested change
"Toggle to unsharpen the overlay image to remove the edges and finer details within an image.",
"Toggle to apply unsharpen mask to the overlay image to enhance edge contrast and make details appear clearer.",

Copilot uses AI. Check for mistakes.
Comment on lines +3313 to +3317
const offsetX = Number(shadowOffsetX)
if (!Number.isNaN(offsetX) && offsetX < 0) {
params.push(`x-N${Math.abs(offsetX)}`)
} else {
params.push(`x-${shadowOffsetX}`)
params.push(`x-${offsetX}`)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

When offsetX is NaN (e.g., if shadowOffsetX is a non-numeric string), the code pushes x-NaN to params. Add an early return or guard to skip processing when the conversion results in NaN.

Copilot uses AI. Check for mistakes.
Comment on lines +3326 to +3330
const offsetY = Number(shadowOffsetY)
if (!Number.isNaN(offsetY) && offsetY < 0) {
params.push(`y-N${Math.abs(offsetY)}`)
} else {
params.push(`y-${shadowOffsetY}`)
params.push(`y-${offsetY}`)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

When offsetY is NaN (e.g., if shadowOffsetY is a non-numeric string), the code pushes y-NaN to params. Add an early return or guard to skip processing when the conversion results in NaN.

Copilot uses AI. Check for mistakes.
Comment on lines +3681 to +3686
const { unsharpenMaskRadius, unsharpenMaskSigma, unsharpenMaskAmount, unsharpenMaskThreshold } = values as {
unsharpenMaskRadius: number
unsharpenMaskSigma: number
unsharpenMaskAmount: number
unsharpenMaskThreshold: number
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The formatter unconditionally builds the transform string even when the required fields may be undefined. This could produce invalid transforms like undefined-undefined-undefined-undefined. Add validation to ensure all four parameters exist before constructing the transform, or check if unsharpenMask is enabled.

Suggested change
const { unsharpenMaskRadius, unsharpenMaskSigma, unsharpenMaskAmount, unsharpenMaskThreshold } = values as {
unsharpenMaskRadius: number
unsharpenMaskSigma: number
unsharpenMaskAmount: number
unsharpenMaskThreshold: number
}
const {
unsharpenMaskRadius,
unsharpenMaskSigma,
unsharpenMaskAmount,
unsharpenMaskThreshold,
} = values as {
unsharpenMaskRadius: number
unsharpenMaskSigma: number
unsharpenMaskAmount: number
unsharpenMaskThreshold: number
}
if (
typeof unsharpenMaskRadius !== "number" ||
typeof unsharpenMaskSigma !== "number" ||
typeof unsharpenMaskAmount !== "number" ||
typeof unsharpenMaskThreshold !== "number"
) {
return
}

Copilot uses AI. Check for mistakes.
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.

2 participants