@@ -1539,31 +1539,30 @@ bool
15391539ImageInput::check_open (const ImageSpec& spec, ROI range, uint64_t /* flags*/ )
15401540{
15411541 // Check for sensible resolutions, etc.
1542- if ((m_spec.width <= 0 || m_spec.height <= 0 || m_spec.depth <= 0
1543- || m_spec.nchannels <= 0 )
1544- && !supports (" noimage" )) {
1542+ if (spec.width == 0 && spec.height == 0 && spec.nchannels == 0
1543+ && supports (" noimage" )) {
1544+ // ok!
1545+ } else if (spec.width <= 0 || spec.height <= 0 || spec.depth <= 0
1546+ || spec.nchannels <= 0 ) {
15451547 errorfmt (
1546- " {} image resolution must be at least 1x1, but the file specified {}x{}. Possible corrupt input?" ,
1547- format_name (), m_spec .width , m_spec .height );
1548+ " {} image resolution must be at least 1x1, but the file specified {}x{}x{}, {} chans . Possible corrupt input?" ,
1549+ format_name (), spec .width , spec .height , spec. depth , spec. nchannels );
15481550 return false ;
15491551 }
1550- if (m_spec. depth > 1 ) {
1551- if (m_spec. width > range. width () || m_spec. height > range.height ()
1552- || m_spec .depth > range. depth () ) {
1552+ if (spec. width > range. width () || spec. height > range. height ()
1553+ || spec. depth > range.depth ()) {
1554+ if (spec .depth > 1 ) {
15531555 errorfmt (
15541556 " {} image resolution may not exceed {}x{}x{}, but the file appears to be {}x{}x{}. Possible corrupt input?" ,
15551557 format_name (), range.width (), range.height (), range.depth (),
1556- m_spec.width , m_spec.height , m_spec.depth );
1557- return false ;
1558- }
1559- } else {
1560- if (m_spec.width > range.width () || m_spec.height > range.height ()) {
1558+ spec.width , spec.height , spec.depth );
1559+ } else if (spec.width > range.width () || spec.height > range.height ()) {
15611560 errorfmt (
15621561 " {} image resolution may not exceed {}x{}, but the file appears to be {}x{}. Possible corrupt input?" ,
1563- format_name (), range.width (), range.height (), m_spec.width ,
1564- m_spec.height );
1565- return false ;
1562+ format_name (), range.width (), range.height (), spec.width ,
1563+ spec.height );
15661564 }
1565+ return false ;
15671566 }
15681567 if (spec.nchannels > range.nchannels ()) {
15691568 errorfmt (
@@ -1585,12 +1584,37 @@ ImageInput::check_open(const ImageSpec& spec, ROI range, uint64_t /*flags*/)
15851584 " Uncompressed image size {:.1f} MB exceeds the {} MB limit.\n "
15861585 " Image claimed to be {}x{}, {}-channel {}. Possible corrupt input?\n "
15871586 " If this is a valid file, raise the OIIO attribute \" limits:imagesize_MB\" ." ,
1588- float (m_spec .image_bytes (true )) / float (1024 * 1024 ),
1589- OIIO::pvt::limit_imagesize_MB, m_spec .width , m_spec .height ,
1590- m_spec .nchannels , m_spec .format );
1587+ float (spec .image_bytes (true )) / float (1024 * 1024 ),
1588+ OIIO::pvt::limit_imagesize_MB, spec .width , spec .height ,
1589+ spec .nchannels , spec .format );
15911590 return false ;
15921591 }
15931592
1593+ // Check for invalid full_* values for sensibility
1594+ if (spec.full_width == 0 && spec.full_height == 0 && spec.full_depth == 0
1595+ && supports (" noimage" )) {
1596+ // ok!
1597+ } else if (spec.full_width <= 0 || spec.full_height <= 0
1598+ || spec.full_depth <= 0 ) {
1599+ errorfmt (
1600+ " {} image full/display resolution must be at least 1x1, but the file specified {}x{}x{}. Possible corrupt input?" ,
1601+ format_name (), spec.full_width , spec.full_height , spec.full_depth );
1602+ return false ;
1603+ }
1604+ if (spec.full_width > range.width () || spec.full_height > range.height ()
1605+ || spec.full_depth > range.depth ()) {
1606+ if (spec.full_depth > 1 )
1607+ errorfmt (
1608+ " {} image full/display resolution may not exceed {}x{}x{}, but the file appears to be {}x{}x{}. Possible corrupt input?" ,
1609+ format_name (), range.width (), range.height (), range.depth (),
1610+ spec.full_width , spec.full_height , spec.full_depth );
1611+ else
1612+ errorfmt (
1613+ " {} image full/display resolution may not exceed {}x{}, but the file appears to be {}x{}. Possible corrupt input?" ,
1614+ format_name (), range.width (), range.height (), spec.full_width ,
1615+ spec.full_height );
1616+ return false ;
1617+ }
15941618 return true ; // all is ok
15951619}
15961620
0 commit comments