File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -388,14 +388,9 @@ impl<'a> BlobObject<'a> {
388388 _ => img,
389389 } ;
390390
391- // max_wh is the maximum image width and height, i.e. the resolution-limit.
392- // target_wh target-resolution for resizing the image .
391+ // max_wh is the maximum image width and height, i.e. the resolution-limit,
392+ // as set by `Config::MediaQuality` .
393393 let exceeds_wh = img. width ( ) > max_wh || img. height ( ) > max_wh;
394- let mut target_wh = if exceeds_wh {
395- max_wh
396- } else {
397- max ( img. width ( ) , img. height ( ) )
398- } ;
399394 let exceeds_max_bytes = nr_bytes > max_bytes as u64 ;
400395
401396 let jpeg_quality = 75 ;
@@ -434,6 +429,14 @@ impl<'a> BlobObject<'a> {
434429 } ) ;
435430
436431 if do_scale {
432+ // target_wh will be used as the target-resolution for resizing the image,
433+ // so that the longest sides of the image match the target-resolution.
434+ let mut target_wh = if exceeds_wh {
435+ max_wh
436+ } else {
437+ max ( img. width ( ) , img. height ( ) )
438+ } ;
439+
437440 loop {
438441 if mem:: take ( & mut add_white_bg) {
439442 self :: add_white_bg ( & mut img) ;
You can’t perform that action at this time.
0 commit comments