Step-by-Step Workflow
1. Open the Settings rail
The left rail contains one workspace: Settings. Select it to reveal the image upload control and scaling options in the master pane. The project compares the same source image across three fixed aspect-ratio surfaces.
2. Provide an image
Use the upload area to choose an image from your device. Images are processed in the browser. If no custom image is loaded, choose one of the built-in portrait, landscape, or square sample images from Default Image Format.
3. Choose X and Y alignment
Min, Mid, and Max control which part of the image remains anchored when Meet or Slice changes the visible crop. For example, X = Max and Y = Min keeps the upper-right region aligned while excess content is cropped.
4. Choose the fit mode: Meet or Slice
Meet fits the complete image inside each container and may leave letterboxed space. Slice fills the complete container and crops overflow. Change the mode to compare how the same source behaves in landscape, portrait, and square surfaces.
5. Select Canvas or SVG implementation
Use the canvas header tabs to compare the two rendering implementations. Canvas uses the 2D drawImage API with calculated source and destination rectangles; SVG uses native image scaling and preserveAspectRatio behavior.
6. Compare the three output surfaces
Each view shows landscape (280×200), portrait (200×280), and square (200×200) output. Compare cropping, empty space, and focal alignment across all three shapes rather than judging only one preview.
7. Read the current setting
The topbar status displays the active composite setting, such as xMidYMid meet or xMaxYMin slice. Use it to record or reproduce a particular comparison configuration.
8. Reset the experiment
Reset restores the default alignment and fit controls. Clearing an uploaded image returns the demo to the selected built-in sample image. Reset does not export or persist an image; it only restores the current workspace state.
Technical Specs & FAQs
Settings rail and master pane
The Settings rail item opens the only control pane in this project. The pane contains upload/input controls and four selectors: X Alignment, Y Alignment, Fit Mode, and Default Image Format. Default Image Format is shown only when a custom upload is not active.
Upload behavior
The shared image upload control validates the selected file before the component creates an in-memory HTMLImageElement. The image is rendered locally into Canvas and SVG previews. Selecting a custom image hides the built-in format selector until the image is cleared.
Meet versus Slice
Meet calculates a scale that keeps the entire source image visible inside the destination rectangle. Slice calculates a scale that fills the destination rectangle, then uses X/Y alignment to decide which overflow remains visible.
Alignment model
The component combines the selected values into a string such as xMidYMid meet. Min, Mid, and Max are applied independently to the horizontal and vertical axes, allowing nine focal positions for each fit mode.
Canvas implementation
The Canvas view uses three fixed-size canvas elements and recalculates their drawing rectangles when controls change or the container is resized. The component keeps the preview elements mounted so their rendering contexts remain stable.
SVG implementation
The SVG view uses three native SVG image elements with matching viewBox dimensions. It provides a direct comparison against Canvas scaling and alignment behavior. Switching tabs changes visibility while preserving the preview elements.
Responsive redraw
A ResizeObserver watches the canvas content region and redraws the previews when the available space changes. This keeps the comparison usable when the shell pane is collapsed, the viewport changes size, or the application enters a compact layout.
Troubleshooting: blank preview
If a preview is blank, wait for the sample image to finish loading or choose another built-in format. For a custom file, confirm that it is a supported image type and reselect it if the browser did not finish decoding it.
Troubleshooting: unexpected crop
Slice intentionally crops overflow. Try Meet to display the complete image, or change X Alignment and Y Alignment to move the focal area toward Min, Mid, or Max. The topbar composite setting confirms the active values.
Privacy and processing
Uploaded images are read and rendered in the browser. The component uses local image, Canvas, SVG, and ResizeObserver APIs; it does not send the selected image to an application backend.