Fix saving grayscale WebP images (#2591)

pull/2600/head
Adrià Arrufat 2 years ago committed by GitHub
parent c9a25fda0a
commit 1de7924694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -76,7 +76,7 @@ namespace dlib
auto data = reinterpret_cast<const uint8_t*>(image_data(img));
const int width = img.nc();
const int height = img.nr();
const int stride = width_step(img);
int stride = width_step(img);
if (pixel_traits<pixel_type>::rgb_alpha)
{
if (pixel_traits<pixel_type>::bgr_layout)
@ -94,8 +94,10 @@ namespace dlib
else
{
// This is some other kind of color image so just save it as an RGB image.
// We also need to recompute the stride in case we were given a grayscale image.
array2d<rgb_pixel> temp;
assign_image(temp, img);
stride = width_step(temp);
auto data = reinterpret_cast<const uint8_t*>(image_data(temp));
impl::impl_save_webp(filename, data, width, height, stride, quality, impl::webp_type::rgb);
}

@ -16,6 +16,7 @@ New Features and Improvements:
Non-Backwards Compatible Changes:
Bug fixes:
- Fix saving grayscale WebP images (PR #2591)
</current>
<!-- ************************************************************************************** -->

Loading…
Cancel
Save