mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: force PNG output for TIFF when alpha is required
Sharp's TIFF encoder silently strips the alpha channel, flattening transparency against black. This caused border (corner radius, shadow), beautify, and replace-color tools to produce wrong output for TIFF inputs when the operation needs transparency. Remove TIFF from ALPHA_FORMATS so these tools fall back to PNG output.
This commit is contained in:
@@ -27,7 +27,7 @@ import { decompressSvgz, sanitizeSvg } from "../../lib/svg-sanitize.js";
|
||||
import { createWorkspace } from "../../lib/workspace.js";
|
||||
import { registerToolProcessFn } from "../tool-factory.js";
|
||||
|
||||
const ALPHA_FORMATS = new Set(["png", "webp", "avif", "tiff"]);
|
||||
const ALPHA_FORMATS = new Set(["png", "webp", "avif"]);
|
||||
|
||||
function escapeXml(text: string): string {
|
||||
return text
|
||||
|
||||
@@ -146,7 +146,7 @@ export function registerBorder(app: FastifyInstance) {
|
||||
}
|
||||
|
||||
const outputFormat = await resolveOutputFormat(inputBuffer, filename);
|
||||
const ALPHA_FORMATS = new Set(["png", "webp", "avif", "tiff"]);
|
||||
const ALPHA_FORMATS = new Set(["png", "webp", "avif"]);
|
||||
const needsAlpha = settings.cornerRadius > 0 || settings.shadow;
|
||||
|
||||
if (needsAlpha && !ALPHA_FORMATS.has(outputFormat.format)) {
|
||||
|
||||
@@ -75,7 +75,7 @@ export function registerReplaceColor(app: FastifyInstance) {
|
||||
}
|
||||
|
||||
const outputFormat = await resolveOutputFormat(inputBuffer, filename);
|
||||
const ALPHA_FORMATS = new Set(["png", "webp", "avif", "tiff"]);
|
||||
const ALPHA_FORMATS = new Set(["png", "webp", "avif"]);
|
||||
const needsAlpha = settings.makeTransparent;
|
||||
const useFormat =
|
||||
needsAlpha && !ALPHA_FORMATS.has(outputFormat.format)
|
||||
|
||||
Reference in New Issue
Block a user