Skip to content

Commit

Permalink
Merge #8
Browse files Browse the repository at this point in the history
8: Convert non-rgba8 images to rgba instead of panic r=torkleyy a=qthree

Previously `sheep_cli` was panicking on opaque png or bmp images. Now it should convert such images to expected `rgba` format. This change is zero cost for the images of `rgba8` format.

Co-authored-by: qthree <qthree3@gmail.com>
  • Loading branch information
bors[bot] and qthree committed May 18, 2019
2 parents ef813eb + c4cee33 commit 9d94a3e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sheep_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ where

for path in input {
let img = image::open(&path).expect("Failed to open image");
let img = img.as_rgba8().expect("Failed to convert image to rgba8");
let img_owned;
let img = {
if let Some(img) = img.as_rgba8() {
img
} else {
img_owned = img.to_rgba();
&img_owned
}
};

let dimensions = img.dimensions();
let bytes = img
Expand Down

0 comments on commit 9d94a3e

Please sign in to comment.