Skip to content

Commit

Permalink
BUG Fix strip_alpha for RGBA PNGs
Browse files Browse the repository at this point in the history
  • Loading branch information
luispedro committed Sep 19, 2016
1 parent 4bc08a7 commit 0869ce1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion imread/lib/_png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ std::auto_ptr<Image> PNGFormat::read(byte_source* src, ImageFactory* factory, co
d = 3;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
d = 4;
d = 4 - int(strip_alpha);
break;
case PNG_COLOR_TYPE_GRAY:
d = -1;
Expand Down
Binary file added imread/tests/data/rgba.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions imread/tests/test_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ def test_write_16bit():
imsave(_filename, f)
f2 = imread(_filename)
assert np.all(f == f2)


def test_strip_alpha():
w_alpha = imread(file_path('rgba.png'))
wno_alpha = imread(file_path('rgba.png'), opts={'strip_alpha':True})
assert np.all(w_alpha[:,:,:3] == wno_alpha)

0 comments on commit 0869ce1

Please sign in to comment.