Skip to content

Loading a PNG drops the alpha channel #440

@Nateowami

Description

@Nateowami

When I load a PNG image only 3 channels are loaded into the matrix:

cv.readImage('path/to/image.png', function(err, img){
  if(err) throw err;
  console.log(img.channels()); // Prints '3'
  img.save('out.png');
});

When the file is saved, it is saved without an alpha channel. Looking at the source code for OpenCV.cc I see the image is loaded with cv::imread(filename, CV_LOAD_IMAGE_UNCHANGED). I understood from other sources that CV_LOAD_IMAGE_UNCHANGED should preserve the alpha channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions