feat(frame): give ROTATE quarter turns plus a fine straighten
This commit is contained in:
@@ -9,7 +9,7 @@ import { TONE_SKSL, getToneUniforms, toneIsActive, toneUniformArray } from './to
|
||||
import { CINEMA_SKSL, getCinemaUniforms, cinemaIsActive } from './cinemaShader';
|
||||
import { drawFrameOnCanvas, polaroidLayout, POLAROID_CARD, POLAROID_WIN_W, wallframeLayout, WALLFRAME_W, WALLFRAME_H, WALLFRAME_LAND_W, WALLFRAME_LAND_H } from './frameUtils';
|
||||
import { patchJpegDpi } from './jpegDpi';
|
||||
import { rotateSkImage90 } from './skiaImage';
|
||||
import { applyPhotoRotation } from './skiaImage';
|
||||
|
||||
export interface ExportResult {
|
||||
uri: string;
|
||||
@@ -70,10 +70,12 @@ export interface ExportOptions {
|
||||
// visible through the opening, so the file matches the preview. Null /
|
||||
// undefined = centered 1x (the historical full-image draw).
|
||||
frameWindowZoom?: { s: number; u: number; v: number } | null;
|
||||
// Library FRAME-tab rotation (90 = clockwise). Applied to the decoded source
|
||||
// before the ratio crop, so the frame layout and cover maths see exactly the
|
||||
// orientation the preview showed.
|
||||
photoRotation?: 0 | 90;
|
||||
// Library FRAME-tab rotation: the quarter turn in degrees clockwise
|
||||
// (0/90/180/270) and the fine STRAIGHTEN offset in degrees, applied to the
|
||||
// decoded source before the ratio crop, so the frame layout and cover maths
|
||||
// see exactly the orientation the preview showed.
|
||||
photoRotation?: 0 | 90 | 180 | 270;
|
||||
photoStraighten?: number;
|
||||
}
|
||||
|
||||
// Lightroom-style "Screen" output sharpen: subtle unsharp mask. A 3x3
|
||||
@@ -139,7 +141,8 @@ export async function processAndExportPhoto(
|
||||
let skImage = skImage0;
|
||||
// FRAME-tab rotation first: the pixel-dimension swap then propagates
|
||||
// through the ratio crop, frame layout and cover maths unchanged.
|
||||
if (options?.photoRotation === 90) skImage = rotateSkImage90(skImage) ?? skImage;
|
||||
skImage =
|
||||
applyPhotoRotation(skImage, options?.photoRotation, options?.photoStraighten) ?? skImage;
|
||||
let width = skImage.width();
|
||||
let height = skImage.height();
|
||||
// 1b. Aspect-ratio crop (composition): center-largest upright crop of the
|
||||
@@ -445,7 +448,10 @@ export async function processAndExportPhoto(
|
||||
// Card proportions follow the UN-rotated source, so rotating the print
|
||||
// inside the frame never resizes the frame (same rule as the viewfinder).
|
||||
const frameAspect =
|
||||
ratioWH ?? (options?.photoRotation === 90 ? height / width : width / height);
|
||||
ratioWH ??
|
||||
(options?.photoRotation === 90 || options?.photoRotation === 270
|
||||
? height / width
|
||||
: width / height);
|
||||
const outH = Math.round(
|
||||
width * (POLAROID_CARD.sideMargin + POLAROID_CARD.bottomDeck) +
|
||||
(width * POLAROID_WIN_W) / frameAspect
|
||||
|
||||
Reference in New Issue
Block a user