Skip to content

Commit 9bccd5a

Browse files
andfoydatumbox
andauthored
Fix ternary operator to decide to store an image in Grayscale or RGB (#3553)
Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent 0e80296 commit 9bccd5a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/csrc/io/image/cpu/encode_png.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {
128128
png_set_write_fn(png_write, &buf_info, torch_png_write_data, NULL);
129129

130130
// Set output image information
131-
auto color_type = PNG_COLOR_TYPE_GRAY ? channels == 1 : PNG_COLOR_TYPE_RGB;
131+
auto color_type = channels == 1 ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_RGB;
132132
png_set_IHDR(
133133
png_write,
134134
info_ptr,

0 commit comments

Comments
 (0)