mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: unify project on port 1349, improve strip-metadata and UI components
Consolidate all access to localhost:1349 — Vite dev server serves on 1349 and proxies API calls to an internal dev port (13490). Production API defaults to 1349. Also includes strip-metadata improvements, UI component updates, and compress operation fixes.
This commit is contained in:
@@ -3,6 +3,7 @@ import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import type { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
||||
import { z } from "zod";
|
||||
import sharp from "sharp";
|
||||
import { createWorkspace } from "../lib/workspace.js";
|
||||
import { validateImageBuffer } from "../lib/file-validation.js";
|
||||
import { sanitizeFilename } from "../lib/filename.js";
|
||||
@@ -125,9 +126,24 @@ export function createToolRoute<T>(
|
||||
return reply.status(400).send({ error: "Settings must be valid JSON" });
|
||||
}
|
||||
|
||||
// Auto-orient based on EXIF metadata before processing.
|
||||
// Camera photos often have EXIF orientation tags (values 2-8) that browsers
|
||||
// respect when displaying, but Sharp does NOT apply by default. Without this,
|
||||
// processed images appear rotated because the output (PNG) strips EXIF data.
|
||||
// Only re-encodes when orientation correction is actually needed.
|
||||
let processBuffer = fileBuffer;
|
||||
try {
|
||||
const meta = await sharp(fileBuffer).metadata();
|
||||
if (meta.orientation && meta.orientation > 1) {
|
||||
processBuffer = await sharp(fileBuffer).rotate().toBuffer();
|
||||
}
|
||||
} catch {
|
||||
// If metadata reading fails, proceed with original buffer
|
||||
}
|
||||
|
||||
// Process the image
|
||||
try {
|
||||
const result = await config.process(fileBuffer, settings, filename);
|
||||
const result = await config.process(processBuffer, settings, filename);
|
||||
|
||||
// Create workspace and save output
|
||||
const jobId = randomUUID();
|
||||
|
||||
Reference in New Issue
Block a user