Skip to content

Commit 539aba4

Browse files
authored
int(webp,jpeg-xl): Added check_open for WebP and JPEG XL readers (#5202)
This PR addresses the feature request in issue #3974 Continuing from previous work done on this feature request, I have added `check_open` calls to two new format readers, using file format specs found online: - WebP: https://developers.google.com/speed/webp/faq#what_is_the_maximum_size_a_webp_image_can_be - JPEG XL: https://jpegxl.info/resources/battle-of-codecs.html I also cross-referenced this info with the corresponding ImageOutput::check_open calls for sanity, and they seemed to align. Signed-off-by: Hannah Gulka <hannahkg8@gmail.com>
1 parent 1711c39 commit 539aba4

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/jpegxl.imageio/jxlinput.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ JxlInput::open(const std::string& name, ImageSpec& newspec)
360360

361361
m_spec = ImageSpec(info.xsize, info.ysize, m_channels, m_data_type);
362362

363+
if (!check_open(m_spec,
364+
{ 0, (1 << 30) - 1, 0, (1 << 30) - 1, 0, 1, 0, 4099 }))
365+
return false;
366+
363367
// Read ICC profile
364368
if (m_icc_profile.size() && m_icc_profile.data()) {
365369
m_spec.attribute("ICCProfile",

src/webp.imageio/webpinput.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ WebpInput::open(const std::string& name, ImageSpec& spec,
233233
m_spec.attribute("oiio:UnassociatedAlpha", 1);
234234
}
235235

236+
if (!check_open(m_spec, { 0, (1 << 14) - 1, 0, (1 << 14) - 1, 0, 1, 0, 4 }))
237+
return false;
238+
236239
seek_subimage(0, 0);
237240
spec = m_spec;
238241
return true;

0 commit comments

Comments
 (0)