Actualizacion 7.1.2
This commit is contained in:
+26
-8
@@ -52894,9 +52894,7 @@ var vips_heif_default = bytes2;
|
||||
|
||||
// packages/vips/src/utils.ts
|
||||
function supportsQuality(type) {
|
||||
return ["image/jpeg", "image/png", "image/webp", "image/avif"].includes(
|
||||
type
|
||||
);
|
||||
return ["image/jpeg", "image/webp", "image/avif"].includes(type);
|
||||
}
|
||||
function supportsAnimation(type) {
|
||||
return ["image/webp", "image/gif"].includes(type);
|
||||
@@ -52999,6 +52997,9 @@ async function convertImageFormat(id, buffer, inputType, outputType, options = {
|
||||
if (interlaced && supportsInterlace(outputType)) {
|
||||
saveOptions.interlace = interlaced;
|
||||
}
|
||||
if ("image/png" === outputType && isPaletteImage(image)) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
if ("image/avif" === outputType) {
|
||||
saveOptions.effort = 2;
|
||||
const sourceBitdepth = getSourceBitdepth(image);
|
||||
@@ -53090,6 +53091,9 @@ function applyResizeAndCrop(resize, originalWidth, originalHeight, smartCrop, cr
|
||||
setImage.call(result, "gainmap", newGainmap);
|
||||
return result;
|
||||
}
|
||||
function isPaletteImage(image) {
|
||||
return image.getTypeof("palette") !== 0;
|
||||
}
|
||||
function getSourceBitdepth(image) {
|
||||
try {
|
||||
const bitdepth = image.getInt("heif-bitdepth");
|
||||
@@ -53110,7 +53114,13 @@ function resolveSaveBitdepth(sourceBitdepth, maxBitdepth) {
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
function buildSaveOptions(type, quality, bitdepth = 8, stripMeta = true) {
|
||||
function buildSaveOptions({
|
||||
type,
|
||||
quality,
|
||||
bitdepth = 8,
|
||||
stripMeta = true,
|
||||
isPalette = false
|
||||
}) {
|
||||
const saveOptions = {
|
||||
// Strip metadata except ICC color profiles or gainmaps,
|
||||
// matching WordPress core's behavior. The \`image_strip_meta\`
|
||||
@@ -53120,6 +53130,9 @@ function buildSaveOptions(type, quality, bitdepth = 8, stripMeta = true) {
|
||||
if (supportsQuality(type)) {
|
||||
saveOptions.Q = quality * 100;
|
||||
}
|
||||
if ("image/png" === type && isPalette) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
if ("image/avif" === type) {
|
||||
saveOptions.effort = 2;
|
||||
if (bitdepth > 8) {
|
||||
@@ -53208,12 +53221,13 @@ async function resizeImage(id, buffer, type, resize, options = {}) {
|
||||
return thumb;
|
||||
}
|
||||
);
|
||||
const saveOptions = buildSaveOptions(
|
||||
const saveOptions = buildSaveOptions({
|
||||
type,
|
||||
quality,
|
||||
saveBitdepth,
|
||||
stripMeta
|
||||
);
|
||||
bitdepth: saveBitdepth,
|
||||
stripMeta,
|
||||
isPalette: isPaletteImage(sourceImage)
|
||||
});
|
||||
const outBuffer = image.writeToBuffer(\`.\${ext}\`, saveOptions);
|
||||
const result = {
|
||||
buffer: outBuffer.buffer,
|
||||
@@ -53271,6 +53285,7 @@ async function rotateImage(id, buffer, type, orientation) {
|
||||
image.kill = true;
|
||||
}
|
||||
};
|
||||
const isPalette = isPaletteImage(image);
|
||||
switch (orientation) {
|
||||
case 2:
|
||||
image = image.flipHor();
|
||||
@@ -53296,6 +53311,9 @@ async function rotateImage(id, buffer, type, orientation) {
|
||||
}
|
||||
image.remove("orientation");
|
||||
const saveOptions = {};
|
||||
if ("image/png" === type && isPalette) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
const outBuffer = image.writeToBuffer(\`.\${ext}\`, saveOptions);
|
||||
const result = {
|
||||
buffer: outBuffer.buffer,
|
||||
|
||||
Reference in New Issue
Block a user