Skip to content

feat(new tool): Crop Image#404

Open
sYnVerse wants to merge 6 commits into
sharevb:chore/all-my-stuffsfrom
sYnVerse:feat/crop-image
Open

feat(new tool): Crop Image#404
sYnVerse wants to merge 6 commits into
sharevb:chore/all-my-stuffsfrom
sYnVerse:feat/crop-image

Conversation

@sYnVerse
Copy link
Copy Markdown

@sYnVerse sYnVerse commented Jun 6, 2026

Overview

This PR introduces a new Crop Image tool that allows users to crop, resize, rotate, and flip images. It integrates fully with the app's existing 19 locales and includes a layout scaling fix to ensure cropped coordinates match precisely on small and mobile screens.

Features

  1. Interactive Cropper Viewport:
    • Supported options: Rotate (-180° to 180°), Flip (Horizontal & Vertical), Fit, and Reset.
    • Live Rule-of-Thirds grid overlay.
    • Mouse/touch drag-to-position and mouse-wheel zooming.
  2. Flexible Aspect Ratios & Backgrounds:
    • Presets for 1:1, 16:9, 9:16, 4:3, 3:2, Original Image ratio, and Free/Custom input.
    • Support for custom solid background colors or transparent grids.
  3. Advanced Export Settings:
    • Select export formats (PNG, JPEG, WebP) with image quality compression.
    • Export sizes at Original Crop size, Viewport size, or Custom Width (px).
  4. Clean Viewport Scaling Fix:
    • Utilizes CSS transform: scale() dynamically calculated via VueUse's useElementSize ResizeObserver.
    • Ensures dragging and zooming coordinates are mapped correctly to the unscaled baseline (450px) regardless of responsive screen resizing.
  5. Localization (i18n):
    • All buttons, text labels, preset names, and screen tips are localized across all 19 supported language files (locales/*.yml).

Changes

  • New Component: src/tools/crop-image/crop-image.vue
  • Sizing Utilities: src/tools/crop-image/crop-image.service.ts
  • Tests & E2E: src/tools/crop-image/crop-image.service.test.ts, src/tools/crop-image/crop-image.e2e.spec.ts
  • Metadata Registration: src/tools/crop-image/index.ts, src/tools/index.ts
  • Locales: Updates to all 19 locale configuration files in locales/ (re-formatting has been avoided to keep diffs clean).

Pre-submission Verification

The changes have been verified using pre-commit validation checklist:

pnpm install --ignore-scripts
pnpm lint --fix
pnpm typecheck

Dependency Installation: Completed successfully without script issues.
Linting: Verified that the entire src/tools/crop-image folder passes with zero warnings or errors.
Typecheck: Compiled successfully with no TypeScript compilation errors.
Unit Tests: All unit tests pass successfully (npx vitest run src/tools/crop-image).

sYnVerse added 6 commits June 6, 2026 14:21
Introduce a new Crop Image tool: adds an interactive Vue cropper component (src/tools/crop-image/crop-image.vue) with drag/drop upload, viewport cropping, zoom, rotation, horizontal/vertical flip, aspect-ratio presets/custom ratio, rule-of-thirds grid, background color, and export options (PNG/JPEG/WebP, quality and width modes). Also adds tool registration (src/tools/crop-image/index.ts), a placeholder service (crop-image.service.ts), a Vitest unit test (crop-image.service.test.ts) and a Playwright e2e spec stub (crop-image.e2e.spec.ts).
Introduce getViewportDimensions and getBaseDimensions utility functions (src/tools/crop-image/crop-image.service.ts) to centralize viewport/base sizing logic and handle missing natural dimensions. Refactor crop-image.vue to consume these utilities for computed viewport and base dimensions. Add unit tests covering landscape/portrait calculations and cover scaling (src/tools/crop-image/crop-image.service.test.ts) and expand the e2e spec to upload a 1x1 PNG and assert presence of the cropper, sliders and control buttons (src/tools/crop-image/crop-image.e2e.spec.ts). Improves testability and keeps sizing logic consistent across the component.
Resolves an issue where exporting cropped images on small/mobile screens resulted in a different crop than shown in the preview.

- Added reactive viewport scaling tracking using `@vueuse/core` `useElementSize`.
- Wrapped the cropper viewport in a container that scales down via CSS `transform: scale()` to maintain aspect ratios and layout without shrinking coordinates.
- Scaled pointer dragging deltas (`dx`, `dy`) by the scale factor to preserve movement tracking accuracy.
- Cleaned up related ESLint warnings/errors and unused imports in the `crop-image` files."
Add localization entries for a new 'crop-image' tool across multiple locale YAML files (ar, da, de, el, en, es, fr, ga, it, ko, nl, no, pl, pt, ru, tr, uk, vi, zh). Each file adds title and description strings for cropping, resizing, and rotating images with custom background colors.
Add 'texts' translation entries for the crop-image tool across multiple locales (ar, da, de, el, en, es, fr, ga, it, ko, nl, no, pl, pt, ru, tr, uk, vi, zh). Adds UI strings such as drag/drop hints, flip/reset/fit controls, aspect ratio and custom ratio labels, background color, zoom/rotate, rule-of-thirds grid, export settings (format, quality, width), ratio presets and width options. Also fixes a small typo in the Turkish description (và → ve).
Add vue-i18n integration to crop-image.vue and replace hardcoded UI text with t() translation calls. Import useI18n and use t() for button labels, form labels, hints (with interpolation for zoom), and action text. Convert aspect ratio and export width option arrays into computed properties so they can use translated labels. These changes prepare the component for localization without changing functionality.
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.

1 participant