From a55a322939e632e0c562c329e716c58f0092f4fe Mon Sep 17 00:00:00 2001 From: Robbie Straw Date: Mon, 13 Mar 2017 18:35:50 -0500 Subject: [PATCH] (fix) I don't wanna talk about it. --- src/util/processing/image_detector.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/util/processing/image_detector.rs b/src/util/processing/image_detector.rs index 6a4b224..a8c1916 100644 --- a/src/util/processing/image_detector.rs +++ b/src/util/processing/image_detector.rs @@ -91,6 +91,17 @@ pub fn process_image(content_store: &str, digest: &str, buf: &[u8]) -> super::Re let bucket_dir = dest.parent().ok_or(super::Error::ThumbnailFailed)?; fs::create_dir_all(bucket_dir)?; let mut dest_file = File::create(&dest)?; - thumb.save(&mut dest_file, image::ImageFormat::JPEG)?; + + + { + // HACK: force image to be saved as rgba, grayscale jpg thumbnails are broken + // (for some reason they come out all white) + let rgba_image = thumb.to_rgba(); + let bytes = rgba_image.into_raw(); + let mut encoder = ::image::jpeg::JPEGEncoder::new(&mut dest_file); + encoder.encode(&bytes, 200, 200, ::image::ColorType::RGBA(8))?; + } + + // thumb.save(&mut dest_file, image::ImageFormat::JPEG)?; Ok(dest_file.flush()?) } -- 2.45.2