mirror of
https://github.com/denoland/deno.git
synced 2025-02-07 23:06:50 -05:00
temporarily remove gif
and webp
support due to increasing build size
This commit is contained in:
parent
ca52fe82f8
commit
c63ccdbfa3
5 changed files with 66 additions and 74 deletions
43
Cargo.lock
generated
43
Cargo.lock
generated
|
@ -945,12 +945,6 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
|
@ -3745,16 +3739,6 @@ dependencies = [
|
|||
"polyval",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.29.0"
|
||||
|
@ -4519,25 +4503,12 @@ checksum = "bc144d44a31d753b02ce64093d532f55ff8dc4ebf2ffb8a63c0dda691385acae"
|
|||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder-lite",
|
||||
"color_quant",
|
||||
"gif",
|
||||
"image-webp",
|
||||
"num-traits",
|
||||
"png",
|
||||
"zune-core",
|
||||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image-webp"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e031e8e3d94711a9ccb5d6ea357439ef3dcbed361798bd4071dc4d9793fbe22f"
|
||||
dependencies = [
|
||||
"byteorder-lite",
|
||||
"quick-error 2.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "import_map"
|
||||
version = "0.21.0"
|
||||
|
@ -6241,12 +6212,6 @@ version = "1.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
||||
|
||||
[[package]]
|
||||
name = "quick-junit"
|
||||
version = "0.3.6"
|
||||
|
@ -6580,7 +6545,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00"
|
||||
dependencies = [
|
||||
"hostname",
|
||||
"quick-error 1.2.3",
|
||||
"quick-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -8995,12 +8960,6 @@ dependencies = [
|
|||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.21.1"
|
||||
|
|
|
@ -258,12 +258,28 @@ function createImageBitmap(
|
|||
mimeType = 2;
|
||||
} else if (mimeTypeString === "image/gif") {
|
||||
mimeType = 3;
|
||||
// NOTE: Temporarily not supported due to build size concerns
|
||||
// https://github.com/denoland/deno/pull/25517#issuecomment-2626044644
|
||||
return PromiseReject(
|
||||
new DOMException(
|
||||
"The MIME type of source image is not supported currently",
|
||||
"InvalidStateError",
|
||||
),
|
||||
);
|
||||
} else if (mimeTypeString === "image/bmp") {
|
||||
mimeType = 4;
|
||||
} else if (mimeTypeString === "image/x-icon") {
|
||||
mimeType = 5;
|
||||
} else if (mimeTypeString === "image/webp") {
|
||||
mimeType = 6;
|
||||
// NOTE: Temporarily not supported due to build size concerns
|
||||
// https://github.com/denoland/deno/pull/25517#issuecomment-2626044644
|
||||
return PromiseReject(
|
||||
new DOMException(
|
||||
"The MIME type of source image is not supported currently",
|
||||
"InvalidStateError",
|
||||
),
|
||||
);
|
||||
} else if (mimeTypeString === "") {
|
||||
return PromiseReject(
|
||||
new DOMException(
|
||||
|
|
|
@ -19,7 +19,10 @@ deno_core.workspace = true
|
|||
deno_error.workspace = true
|
||||
deno_terminal.workspace = true
|
||||
deno_webgpu.workspace = true
|
||||
image = { version = "0.25.4", default-features = false, features = ["png", "jpeg", "bmp", "ico", "webp", "gif"] }
|
||||
image = { version = "0.25.4", default-features = false, features = ["png", "jpeg", "bmp", "ico" # NOTE: Temporarily not supported due to build size concerns
|
||||
# https://github.com/denoland/deno/pull/25517#issuecomment-2626044644
|
||||
# "webp", "gif"
|
||||
] }
|
||||
# NOTE: The qcms is a color space conversion crate which parses ICC profiles that used in Gecko,
|
||||
# however it supports only 8-bit color depth currently.
|
||||
# https://searchfox.org/mozilla-central/rev/f09e3f9603a08b5b51bf504846091579bc2ff531/gfx/qcms/src/transform.rs#130-137
|
||||
|
|
|
@ -7,11 +7,11 @@ use deno_core::op2;
|
|||
use deno_core::JsBuffer;
|
||||
use deno_core::ToJsBuffer;
|
||||
use image::codecs::bmp::BmpDecoder;
|
||||
use image::codecs::gif::GifDecoder;
|
||||
// use image::codecs::gif::GifDecoder;
|
||||
use image::codecs::ico::IcoDecoder;
|
||||
use image::codecs::jpeg::JpegDecoder;
|
||||
use image::codecs::png::PngDecoder;
|
||||
use image::codecs::webp::WebPDecoder;
|
||||
// use image::codecs::webp::WebPDecoder;
|
||||
use image::imageops::overlay;
|
||||
use image::imageops::FilterType;
|
||||
use image::metadata::Orientation;
|
||||
|
@ -122,17 +122,20 @@ fn decode_bitmap_data(
|
|||
)
|
||||
}
|
||||
MimeType::Gif => {
|
||||
// NOTE: Temporarily not supported due to build size concerns
|
||||
// https://github.com/denoland/deno/pull/25517#issuecomment-2626044644
|
||||
unimplemented!();
|
||||
// The GifDecoder decodes the first frame.
|
||||
let mut decoder = GifDecoder::new(BufReader::new(Cursor::new(buf)))
|
||||
.map_err(CanvasError::image_error_to_invalid_image)?;
|
||||
let orientation = decoder.orientation()?;
|
||||
let icc_profile = decoder.icc_profile()?;
|
||||
(
|
||||
DynamicImage::from_decoder(decoder)
|
||||
.map_err(CanvasError::image_error_to_invalid_image)?,
|
||||
orientation,
|
||||
icc_profile,
|
||||
)
|
||||
// let mut decoder = GifDecoder::new(BufReader::new(Cursor::new(buf)))
|
||||
// .map_err(CanvasError::image_error_to_invalid_image)?;
|
||||
// let orientation = decoder.orientation()?;
|
||||
// let icc_profile = decoder.icc_profile()?;
|
||||
// (
|
||||
// DynamicImage::from_decoder(decoder)
|
||||
// .map_err(CanvasError::image_error_to_invalid_image)?,
|
||||
// orientation,
|
||||
// icc_profile,
|
||||
// )
|
||||
}
|
||||
MimeType::Bmp => {
|
||||
let mut decoder = BmpDecoder::new(BufReader::new(Cursor::new(buf)))
|
||||
|
@ -159,18 +162,21 @@ fn decode_bitmap_data(
|
|||
)
|
||||
}
|
||||
MimeType::Webp => {
|
||||
// NOTE: Temporarily not supported due to build size concerns
|
||||
// https://github.com/denoland/deno/pull/25517#issuecomment-2626044644
|
||||
unimplemented!();
|
||||
// The WebPDecoder decodes the first frame.
|
||||
let mut decoder =
|
||||
WebPDecoder::new(BufReader::new(Cursor::new(buf)))
|
||||
.map_err(CanvasError::image_error_to_invalid_image)?;
|
||||
let orientation = decoder.orientation()?;
|
||||
let icc_profile = decoder.icc_profile()?;
|
||||
(
|
||||
DynamicImage::from_decoder(decoder)
|
||||
.map_err(CanvasError::image_error_to_invalid_image)?,
|
||||
orientation,
|
||||
icc_profile,
|
||||
)
|
||||
// let mut decoder =
|
||||
// WebPDecoder::new(BufReader::new(Cursor::new(buf)))
|
||||
// .map_err(CanvasError::image_error_to_invalid_image)?;
|
||||
// let orientation = decoder.orientation()?;
|
||||
// let icc_profile = decoder.icc_profile()?;
|
||||
// (
|
||||
// DynamicImage::from_decoder(decoder)
|
||||
// .map_err(CanvasError::image_error_to_invalid_image)?,
|
||||
// orientation,
|
||||
// icc_profile,
|
||||
// )
|
||||
}
|
||||
// This pattern is unreachable due to current block is already checked by the ImageBitmapSource above.
|
||||
MimeType::NoMatch => unreachable!(),
|
||||
|
|
|
@ -258,20 +258,24 @@ Deno.test("imageBitmapFromBlob", async (t) => {
|
|||
[await Deno.readFile(`${prefix}/1x1-red8.gif`)],
|
||||
{ type: "image/gif" },
|
||||
);
|
||||
const imageBitmap = await createImageBitmap(imageData);
|
||||
await assertRejects(() => createImageBitmap(imageData), DOMException);
|
||||
// TODO(Hajime-san): remove the comment out when the implementation is ready
|
||||
// const imageBitmap = await createImageBitmap(imageData);
|
||||
// @ts-ignore: Deno[Deno.internal].core allowed
|
||||
// deno-fmt-ignore
|
||||
assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 255]));
|
||||
// assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 255]));
|
||||
});
|
||||
await t.step("8-bit webp", async () => {
|
||||
const imageData = new Blob(
|
||||
[await Deno.readFile(`${prefix}/1x1-red8.webp`)],
|
||||
{ type: "image/webp" },
|
||||
);
|
||||
const imageBitmap = await createImageBitmap(imageData);
|
||||
await assertRejects(() => createImageBitmap(imageData), DOMException);
|
||||
// TODO(Hajime-san): remove the comment out when the implementation is ready
|
||||
// const imageBitmap = await createImageBitmap(imageData);
|
||||
// @ts-ignore: Deno[Deno.internal].core allowed
|
||||
// deno-fmt-ignore
|
||||
assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 255]));
|
||||
// assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 255]));
|
||||
});
|
||||
await t.step("8-bit ico", async () => {
|
||||
const imageData = new Blob(
|
||||
|
@ -330,10 +334,12 @@ Deno.test("imageBitmapFromBlobAnimatedImage", async (t) => {
|
|||
`${prefix}/1x1-3f-lossless-animated-semi-transparent.webp`,
|
||||
),
|
||||
], { type: "image/webp" });
|
||||
const imageBitmap = await createImageBitmap(imageData);
|
||||
await assertRejects(() => createImageBitmap(imageData), DOMException);
|
||||
// TODO(Hajime-san): remove the comment out when the implementation is ready
|
||||
// const imageBitmap = await createImageBitmap(imageData);
|
||||
// @ts-ignore: Deno[Deno.internal].core allowed
|
||||
// deno-fmt-ignore
|
||||
assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 127]));
|
||||
// assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 127]));
|
||||
});
|
||||
await t.step("animated gif", async () => {
|
||||
// the chunk of animated gif is below (3 frames, 1x1, 8-bit, RGBA)
|
||||
|
@ -343,10 +349,12 @@ Deno.test("imageBitmapFromBlobAnimatedImage", async (t) => {
|
|||
const imageData = new Blob([
|
||||
await Deno.readFile(`${prefix}/1x1-3f-animated.gif`),
|
||||
], { type: "image/gif" });
|
||||
const imageBitmap = await createImageBitmap(imageData);
|
||||
await assertRejects(() => createImageBitmap(imageData), DOMException);
|
||||
// TODO(Hajime-san): remove the comment out when the implementation is ready
|
||||
// const imageBitmap = await createImageBitmap(imageData);
|
||||
// @ts-ignore: Deno[Deno.internal].core allowed
|
||||
// deno-fmt-ignore
|
||||
assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 255]));
|
||||
// assertEquals(Deno[Deno.internal].getBitmapData(imageBitmap), new Uint8Array([255, 0, 0, 255]));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue