diff --git a/src/libOpenImageIO/imagebuf.cpp b/src/libOpenImageIO/imagebuf.cpp index b4f7a93621..1cae86b9c9 100644 --- a/src/libOpenImageIO/imagebuf.cpp +++ b/src/libOpenImageIO/imagebuf.cpp @@ -189,7 +189,7 @@ class ImageBufImpl { TypeDesc pixeltype() const { validate_spec(); - return m_localpixels ? m_spec.format : m_cachedpixeltype; + return cachedpixels() ? m_cachedpixeltype : m_spec.format; } DeepData* deepdata() @@ -1128,6 +1128,7 @@ ImageBufImpl::init_spec(string_view filename, int subimage, int miplevel, if (peltype != TypeDesc::UNKNOWN) { m_spec.format = (TypeDesc::BASETYPE)peltype; m_spec.channelformats.clear(); + m_cachedpixeltype = m_spec.format; } if (m_nsubimages) {