Unverified Commit 95966689 authored by cyy's avatar cyy Committed by GitHub
Browse files

Raise proper error when decoding 16-bits jpegs (#4101)

parent d1ab583d
......@@ -71,6 +71,11 @@ torch::Tensor decode_png(const torch::Tensor& data, ImageReadMode mode) {
TORCH_CHECK(retval == 1, "Could read image metadata from content.")
}
if (bit_depth > 8) {
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
TORCH_CHECK(false, "At most 8-bit PNG images are supported currently.")
}
int channels = png_get_channels(png_ptr, info_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment