Skip to content

Commit

Permalink
Use better JPEG quality
Browse files Browse the repository at this point in the history
  • Loading branch information
matsimitsu committed Mar 3, 2019
1 parent fa11903 commit 92fcc0d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ extern crate serde_derive;
extern crate serde_json;
extern crate simple_logger;

use image::{GenericImageView, ImageError, JPEG};
use image::{ImageOutputFormat, GenericImageView, ImageError};

use rayon::prelude::*;
use s3::bucket::Bucket;
use s3::credentials::Credentials;
Expand Down Expand Up @@ -117,7 +118,7 @@ fn resize_image(img: &image::DynamicImage, new_w: &f32) -> Result<Vec<u8>, Image
let new_h = (old_h * ratio).floor();

let scaled = img.resize(*new_w as u32, new_h as u32, image::FilterType::Lanczos3);
scaled.write_to(&mut result, JPEG)?;
scaled.write_to(&mut result, ImageOutputFormat::JPEG(90))?;

Ok(result)
}

0 comments on commit 92fcc0d

Please sign in to comment.