Skip to content

imdecode ignores IMREAD_REDUCED_* flags #16203

@JamesOldfield

Description

@JamesOldfield

Passing any of the IMREAD_REDUCED_ flags, e.g. IMREAD_REDUCED_GRAYSCALE_2, to the flags parameter of imdecode() has no effect. I notice the imread_() function includes this code:

int scale_denom = 1;
if( flags > IMREAD_LOAD_GDAL )
{
if( flags & IMREAD_REDUCED_GRAYSCALE_2 )
    scale_denom = 2;
else if( flags & IMREAD_REDUCED_GRAYSCALE_4 )
    scale_denom = 4;
else if( flags & IMREAD_REDUCED_GRAYSCALE_8 )
    scale_denom = 8;
}

/// set the scale_denom in the driver
decoder->setScale( scale_denom );

This code is absent in imdecode() (and imdecode_).

For those that aren't familiar with that flag: The expected effect is that the image is resized by the stated factor if it is a JPEG. This happens for "free" due to the way the JPEG encoding works, so it is much faster than opening the image at full resolution and then doing a separate resize.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions