Skip to content

imcount

Image codecsfunctionOpenCV 5.0.0
import { imcount } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSfilename, flags
FUNCTIONimcount
RETURN TYPEnumber
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Returns the number of images inside the given file

The function imcount returns the number of pages in a multi-page image (e.g. TIFF), the number of frames in an animation (e.g. AVIF), and 1 otherwise. If the image cannot be decoded, 0 is returned.

Note: The default flags value was changed from cv::IMREAD_ANYCOLOR to cv::IMREAD_COLOR_BGR for unification. todo: when cv::IMREAD_LOAD_GDAL flag used the return value will be 0 or 1 because OpenCV's GDAL decoder doesn't support multi-page reading yet.

imcount(filename: EmbindString, flags: number): number;
2 available overloads
imcount(filename: EmbindString): number;
imcount(filename: EmbindString, flags: number): number;
filename

Name of file to be loaded.

flags

Flag that can take values of cv::ImreadModes, default with cv::IMREAD_COLOR_BGR.

Returns

The number result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.