feat(plugin-crop): add autocropRect helper#1404
Open
Aniketiitk21 wants to merge 2 commits intojimp-dev:mainfrom
Open
feat(plugin-crop): add autocropRect helper#1404Aniketiitk21 wants to merge 2 commits intojimp-dev:mainfrom
Aniketiitk21 wants to merge 2 commits intojimp-dev:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
image.autocropRect(options)so callers can inspect the exact{ x, y, w, h }rectangle thatautocrop()would applyautocrop()to reuse the same rectangle calculation logic, keeping the mutating crop behavior aligned with the new helper@jimp/plugin-cropand throughjimp@jimp/plugin-print's shell-specificcp -rbuild step with a small Node copy script so the wider Jimp build works on Windows tooWhy
Today
autocrop()can remove borders, but it does not expose the crop rectangle it found. That makes atlas packing, layout alignment, and preflight inspection awkward because consumers have to either rescan the image or mutate it first just to discover the offsets.This adds a small read-only API that returns the same rectangle
autocrop()would use, which means callers can inspect it, store it, or pass it directly intocrop().While validating the change on Windows, the wider
jimp...build surfaced a separate portability problem in@jimp/plugin-print: its build script still depended oncp -r. Fixing that keeps the workspace build path consistent across platforms and removes a real validation blocker.Implementation
autocropRect(options)to@jimp/plugin-cropautocrop()behavior unchanged by making it consume the same computed rectangle@jimp/plugin-printto copy its bundled fonts withnode:fs/promises.cp()instead of a shell-onlycp -rValidation
pnpm exec turbo run build --filter=@jimp/plugin-crop...pnpm exec turbo run test --filter=@jimp/plugin-crop -- --runpnpm --filter @jimp/plugin-crop lintpnpm --filter @jimp/plugin-crop buildpnpm --filter jimp test -- --run src/jimp.test.tspnpm --filter @jimp/plugin-print buildpnpm exec turbo run build --filter=jimp...Closes #801