Skip to content

feat: add image transformations, cropping, and color adjustments#154

Open
PatrykC01 wants to merge 2 commits into
BiometricsUBB:masterfrom
PatrykC01:feature/image-editing-tools
Open

feat: add image transformations, cropping, and color adjustments#154
PatrykC01 wants to merge 2 commits into
BiometricsUBB:masterfrom
PatrykC01:feature/image-editing-tools

Conversation

@PatrykC01

Copy link
Copy Markdown

Summary

  • Adds image transformations in the edit window: rotate 90° left/right, rotate 180°, horizontal flip, and vertical flip.
  • Adds freeform cropping and improves DPI ruler calibration/scaling.
  • Adds pixel-based image adjustments: color inversion, Photoshop/GIMP-like brightness and contrast behavior, and desaturation with color-range sliders.
  • Updates edit preview/save flow so effects are rendered through canvas and saved as real pixel changes instead of CSS-only filters.

Test plan

  • Verified TypeScript check passes during pre-commit.
  • Verified unit tests pass during pre-commit.
  • Manually tested brightness/contrast edge cases against GIMP behavior.
  • Manually tested cropping, transformations, DPI scaling, inversion, and desaturation in the edit window.

canvas.height === sourceHeight
) {
toast.info(
`DPI: skala ${scaleText}x, ` +

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hardcoded pl. use i18next

}

toast.success(
`DPI: skala ${scaleText}x, ` +

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hardcoded pl. use i18next

) {
toast.info(
`DPI: skala ${scaleText}x, ` +
`rozmiar bez zmian (${canvas.width} x ` +

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hardcoded pl. use i18next

Comment thread src/lib/imageModifiers/pipeline.ts Outdated
Comment on lines +196 to +207
const brightnessModifier = [...modifiers]
.reverse()
.find(
(mod): mod is BrightnessModifier =>
mod.enabled && mod.type === "brightness"
);
const contrastModifier = [...modifiers]
.reverse()
.find(
(mod): mod is ContrastModifier =>
mod.enabled && mod.type === "contrast"
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Duplicate modifiers are silently dropped

const ctx = maskCvs.getContext("2d");
ctx?.clearRect(0, 0, maskCvs.width, maskCvs.height);
onChange({ _maskCanvas: maskCvs });
onChange({ _maskCanvas: maskCvs, maskDataUrl: null });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

am i wrong or is maskDataUrl always null?

import { ModifierSettingsDialog } from "@/components/edit-window/modifiers/ModifierSettingsDialog";

const CANVAS_CONTEXT_UNAVAILABLE = "Canvas context unavailable";
const FAILED_TO_SAVE_IMAGE_KEY = "Failed to save image: {{error}}";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A failed rotation/crop is not a save failure - use operation-specific keys


<div className="space-y-1">
<span className="block text-sm font-medium">
Reference length (mm)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hardcoded

setModifiers(prev => [...prev, newMod]);
// Automatically open edit dialog for the new modifier
setEditingModifierId(newMod.id);
setTimeout(() => setEditingModifierId(newMod.id), 50);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like a race workaround

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