Skip to content

Add an image size slider to the crop dialog - #289

Merged
HugoGresse merged 2 commits into
mainfrom
crop-dialog-image-resize
Aug 19, 2026
Merged

Add an image size slider to the crop dialog#289
HugoGresse merged 2 commits into
mainfrom
crop-dialog-image-resize

Conversation

@HugoGresse

@HugoGresse HugoGresse commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Summary

The crop dialog could only cut images — shrinking a heavy photo meant using an external tool. It now has an Image size section, written so anyone understands it: a 10–100% slider, the explanation "smaller images load faster on your website; 100% keeps the original quality", and a live readout — "The image will be saved at 588 × 294 px — 50% of the selected area".

Reducing the size works with or without touching the crop selection (the default selection is the whole image), which was the point: resize without cropping.

Changes

  • src/utils/images/imageCrop/downscaleImage.ts — canvas downscale of a data URL (high-quality interpolation, JPEG saved at 0.9 quality)
  • src/components/sidepanel/ImageCropDialog.tsx — size slider + live dimensions readout, applied to the cropped output on Apply; dialog renamed "Crop & resize image"
  • SVG images show a note instead of the slider: vector files scale without quality loss, there is nothing to reduce

Test plan

  • tsc --noEmit clean
  • Verified end-to-end headlessly against the emulator: 1200×600 PNG → default (full) selection → slider at 50% → readout showed 588 × 294 px → applied → the file delivered to the upload panel measures exactly 588×294
  • Reviewer: try a JPEG and an SVG, check the wording feels clear

🤖 Generated with Claude Code


Note

Low Risk
Client-side image UI and processing only; no auth, APIs, or shared upload contract changes beyond smaller output files when the slider is used.

Overview
The side panel crop flow can now shrink raster images before upload, not only crop them. ImageCropDialog adds an Image size section with a 10–100% slider, copy about faster loads vs. full quality, and a live output width × height readout based on the crop selection’s natural pixels.

On Apply, when the slider is below 100% for JPEG/PNG, the cropped data URL is passed through new downscaleImage (canvas resize with high smoothing; JPEG at 0.9 quality). SVG and unknown types skip resizing and show a short vector-only note instead. The dialog title becomes Crop & resize image and the primary action label is Apply.

Reviewed by Cursor Bugbot for commit 4ab60b5. Configure here.

The crop dialog could only cut images, not shrink them — reducing a
photo's weight required an external tool. The dialog now has an
"Image size" section written for non-technical organizers: a 10-100%
slider with a plain explanation ("smaller images load faster on your
website") and a live "will be saved at W × H px" readout. The scaling
is applied to the cropped output through a canvas downscale (high
quality interpolation, JPEG at 0.9), so picking a smaller size works
with or without moving the crop selection. SVG images show a note
instead: vectors scale without quality loss, there is nothing to
reduce.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@HugoGresse
HugoGresse deployed to GitHub Action PR August 19, 2026 07:46 — with GitHub Actions Active
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit a503abc):

(expires Wed, 26 Aug 2026 07:57:57 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 0c15c45ea5a4c54095387eacf30c3755c9260f22

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4ab60b5. Configure here.

Comment thread src/components/sidepanel/ImageCropDialog.tsx Outdated
Comment thread src/components/sidepanel/ImageCropDialog.tsx
Two review findings from Bugbot:

- Dropzone and clipboard previews are blob: URLs, which detectImageType
  classifies as 'unknown' — the slider was hidden and the SVG note
  shown on the main upload flow. 'unknown' is now resizable: the crop
  path already rasterizes that case as PNG, so the downscale applies
  identically.
- The dialog stays mounted between opens, so a previous reduction
  stayed selected and would silently re-shrink an already-reduced
  image. The percentage now resets to 100 whenever the dialog opens or
  the source image changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@HugoGresse
HugoGresse deployed to GitHub Action PR August 19, 2026 07:56 — with GitHub Actions Active
@HugoGresse
HugoGresse merged commit bdd5981 into main Aug 19, 2026
5 checks passed
@HugoGresse
HugoGresse deleted the crop-dialog-image-resize branch August 19, 2026 08:15
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