ImageDecoder: phương thức tĩnh isTypeSupported()
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Dedicated Web Workers.
Phương thức tĩnh ImageDecoder.isTypeSupported() kiểm tra xem kiểu MIME đã cho có thể được tác nhân người dùng giải mã không.
Cú pháp
js
ImageDecoder.isTypeSupported(type)
Tham số
Giá trị trả về
Một promise được giải quyết với một giá trị boolean cho biết liệu các hình ảnh có định dạng type có thể được giải mã bởi API không.
Ví dụ
Ví dụ sau đây kiểm tra xem hình ảnh GIF và PCX có được hỗ trợ để giải mã không và in kết quả ra console.
js
let isGifSupported = await ImageDecoder.isTypeSupported("image/gif");
console.log(`GIF supported: ${isGifSupported}`); // Likely true.
let isPcxSupported = await ImageDecoder.isTypeSupported("image/pcx");
console.log(`PCX supported: ${isPcxSupported}`); // Probably false
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| WebCodecs> # dom-imagedecoder-istypesupported> |