fix: preserve single-channel scale adjust masks after blur
This commit is contained in:
parent
7640e6b5ca
commit
c79da3e1d0
@ -2132,7 +2132,9 @@ async function buildScaleAdjustMaskWashPatch(params: {
|
||||
const alpha = await sharp(maskBuffer, {
|
||||
raw: { channels: 1, height: box.height, width: box.width },
|
||||
})
|
||||
.greyscale()
|
||||
.blur(Math.max(1.2, Math.min(box.width, box.height) * 0.018))
|
||||
.greyscale()
|
||||
.raw()
|
||||
.toBuffer();
|
||||
const rgba = Buffer.alloc(box.width * box.height * 4);
|
||||
@ -2158,7 +2160,9 @@ async function buildScaleAdjustCompositeClipMaskPatch(params: {
|
||||
const alpha = await sharp(Buffer.from(maskBuffer), {
|
||||
raw: { channels: 1, height: box.height, width: box.width },
|
||||
})
|
||||
.greyscale()
|
||||
.blur(Math.max(0.8, Math.min(box.width, box.height) * 0.006))
|
||||
.greyscale()
|
||||
.raw()
|
||||
.toBuffer();
|
||||
const rgba = Buffer.alloc(box.width * box.height * 4);
|
||||
@ -2183,7 +2187,9 @@ async function buildScaleAdjustOverlayClipMaskPatch(imageBuffer: Buffer) {
|
||||
const alpha = await sharp(imageBuffer, { failOn: "none" })
|
||||
.ensureAlpha()
|
||||
.extractChannel(3)
|
||||
.greyscale()
|
||||
.blur(Math.max(0.8, Math.min(width, height) * 0.006))
|
||||
.greyscale()
|
||||
.raw()
|
||||
.toBuffer();
|
||||
const rgba = Buffer.alloc(width * height * 4);
|
||||
@ -2297,7 +2303,9 @@ async function applyScaleAdjustAlphaMaskToRgba(params: {
|
||||
const softenedAlpha = await sharp(Buffer.from(alphaMask), {
|
||||
raw: { channels: 1, height, width },
|
||||
})
|
||||
.greyscale()
|
||||
.blur(blur)
|
||||
.greyscale()
|
||||
.raw()
|
||||
.toBuffer();
|
||||
const output = Buffer.from(rawRgba);
|
||||
@ -3184,7 +3192,9 @@ async function buildScaleAdjustStructureLockedComposite(params: {
|
||||
const subjectAlpha = await sharp(alphaMaskForSubject, {
|
||||
raw: { channels: 1, height: bbox.height, width: bbox.width },
|
||||
})
|
||||
.greyscale()
|
||||
.blur(Math.max(0.7, Math.min(bbox.width, bbox.height) * 0.006))
|
||||
.greyscale()
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer();
|
||||
const widthFactor =
|
||||
|
||||
@ -2314,7 +2314,9 @@ async function buildScaleAdjustFallbackObjectPng(params: {
|
||||
const alphaBuffer = await sharp(mask, {
|
||||
raw: { channels: 1, height: box.height, width: box.width },
|
||||
})
|
||||
.greyscale()
|
||||
.blur(Math.max(0.7, Math.min(box.width, box.height) * 0.012))
|
||||
.greyscale()
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user