@@ -384,11 +384,13 @@ impl DynamicImage {
384
384
///
385
385
/// Note: this method does *not* modify the object,
386
386
/// and its signature will be replaced with `crop_imm()`'s in the 0.24 release
387
+ #[ must_use]
387
388
pub fn crop ( & mut self , x : u32 , y : u32 , width : u32 , height : u32 ) -> DynamicImage {
388
389
dynamic_map ! ( * self , ref mut p => imageops:: crop( p, x, y, width, height) . to_image( ) )
389
390
}
390
391
391
392
/// Return a cut-out of this image delimited by the bounding rectangle.
393
+ #[ must_use]
392
394
pub fn crop_imm ( & self , x : u32 , y : u32 , width : u32 , height : u32 ) -> DynamicImage {
393
395
dynamic_map ! ( * self , ref p => imageops:: crop_imm( p, x, y, width, height) . to_image( ) )
394
396
}
@@ -653,6 +655,7 @@ impl DynamicImage {
653
655
/// Return a grayscale version of this image.
654
656
/// Returns `Luma` images in most cases. However, for `f32` images,
655
657
/// this will return a grayscale `Rgb/Rgba` image instead.
658
+ #[ must_use]
656
659
pub fn grayscale ( & self ) -> DynamicImage {
657
660
match * self {
658
661
DynamicImage :: ImageLuma8 ( ref p) => DynamicImage :: ImageLuma8 ( p. clone ( ) ) ,
@@ -690,6 +693,7 @@ impl DynamicImage {
690
693
/// Returns a new image. The image's aspect ratio is preserved.
691
694
/// The image is scaled to the maximum possible size that fits
692
695
/// within the bounds specified by `nwidth` and `nheight`.
696
+ #[ must_use]
693
697
pub fn resize ( & self , nwidth : u32 , nheight : u32 , filter : imageops:: FilterType ) -> DynamicImage {
694
698
if ( nwidth, nheight) == self . dimensions ( ) {
695
699
return self . clone ( ) ;
@@ -703,6 +707,7 @@ impl DynamicImage {
703
707
/// Resize this image using the specified filter algorithm.
704
708
/// Returns a new image. Does not preserve aspect ratio.
705
709
/// `nwidth` and `nheight` are the new image's dimensions
710
+ #[ must_use]
706
711
pub fn resize_exact (
707
712
& self ,
708
713
nwidth : u32 ,
@@ -720,6 +725,7 @@ impl DynamicImage {
720
725
/// This method uses a fast integer algorithm where each source
721
726
/// pixel contributes to exactly one target pixel.
722
727
/// May give aliasing artifacts if new size is close to old size.
728
+ #[ must_use]
723
729
pub fn thumbnail ( & self , nwidth : u32 , nheight : u32 ) -> DynamicImage {
724
730
let ( width2, height2) =
725
731
resize_dimensions ( self . width ( ) , self . height ( ) , nwidth, nheight, false ) ;
@@ -732,6 +738,7 @@ impl DynamicImage {
732
738
/// This method uses a fast integer algorithm where each source
733
739
/// pixel contributes to exactly one target pixel.
734
740
/// May give aliasing artifacts if new size is close to old size.
741
+ #[ must_use]
735
742
pub fn thumbnail_exact ( & self , nwidth : u32 , nheight : u32 ) -> DynamicImage {
736
743
dynamic_map ! ( * self , ref p => imageops:: thumbnail( p, nwidth, nheight) )
737
744
}
@@ -742,6 +749,7 @@ impl DynamicImage {
742
749
/// within the larger (relative to aspect ratio) of the bounds
743
750
/// specified by `nwidth` and `nheight`, then cropped to
744
751
/// fit within the other bound.
752
+ #[ must_use]
745
753
pub fn resize_to_fill (
746
754
& self ,
747
755
nwidth : u32 ,
@@ -765,6 +773,7 @@ impl DynamicImage {
765
773
766
774
/// Performs a Gaussian blur on this image.
767
775
/// `sigma` is a measure of how much to blur by.
776
+ #[ must_use]
768
777
pub fn blur ( & self , sigma : f32 ) -> DynamicImage {
769
778
dynamic_map ! ( * self , ref p => imageops:: blur( p, sigma) )
770
779
}
@@ -774,11 +783,13 @@ impl DynamicImage {
774
783
/// `threshold` is a control of how much to sharpen.
775
784
///
776
785
/// See <https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking>
786
+ #[ must_use]
777
787
pub fn unsharpen ( & self , sigma : f32 , threshold : i32 ) -> DynamicImage {
778
788
dynamic_map ! ( * self , ref p => imageops:: unsharpen( p, sigma, threshold) )
779
789
}
780
790
781
791
/// Filters this image with the specified 3x3 kernel.
792
+ #[ must_use]
782
793
pub fn filter3x3 ( & self , kernel : & [ f32 ] ) -> DynamicImage {
783
794
if kernel. len ( ) != 9 {
784
795
panic ! ( "filter must be 3 x 3" )
@@ -790,13 +801,15 @@ impl DynamicImage {
790
801
/// Adjust the contrast of this image.
791
802
/// `contrast` is the amount to adjust the contrast by.
792
803
/// Negative values decrease the contrast and positive values increase the contrast.
804
+ #[ must_use]
793
805
pub fn adjust_contrast ( & self , c : f32 ) -> DynamicImage {
794
806
dynamic_map ! ( * self , ref p => imageops:: contrast( p, c) )
795
807
}
796
808
797
809
/// Brighten the pixels of this image.
798
810
/// `value` is the amount to brighten each pixel by.
799
811
/// Negative values decrease the brightness and positive values increase it.
812
+ #[ must_use]
800
813
pub fn brighten ( & self , value : i32 ) -> DynamicImage {
801
814
dynamic_map ! ( * self , ref p => imageops:: brighten( p, value) )
802
815
}
@@ -805,31 +818,37 @@ impl DynamicImage {
805
818
/// `value` is the degrees to rotate each pixel by.
806
819
/// 0 and 360 do nothing, the rest rotates by the given degree value.
807
820
/// just like the css webkit filter hue-rotate(180)
821
+ #[ must_use]
808
822
pub fn huerotate ( & self , value : i32 ) -> DynamicImage {
809
823
dynamic_map ! ( * self , ref p => imageops:: huerotate( p, value) )
810
824
}
811
825
812
826
/// Flip this image vertically
827
+ #[ must_use]
813
828
pub fn flipv ( & self ) -> DynamicImage {
814
829
dynamic_map ! ( * self , ref p => imageops:: flip_vertical( p) )
815
830
}
816
831
817
832
/// Flip this image horizontally
833
+ #[ must_use]
818
834
pub fn fliph ( & self ) -> DynamicImage {
819
835
dynamic_map ! ( * self , ref p => imageops:: flip_horizontal( p) )
820
836
}
821
837
822
838
/// Rotate this image 90 degrees clockwise.
839
+ #[ must_use]
823
840
pub fn rotate90 ( & self ) -> DynamicImage {
824
841
dynamic_map ! ( * self , ref p => imageops:: rotate90( p) )
825
842
}
826
843
827
844
/// Rotate this image 180 degrees clockwise.
845
+ #[ must_use]
828
846
pub fn rotate180 ( & self ) -> DynamicImage {
829
847
dynamic_map ! ( * self , ref p => imageops:: rotate180( p) )
830
848
}
831
849
832
850
/// Rotate this image 270 degrees clockwise.
851
+ #[ must_use]
833
852
pub fn rotate270 ( & self ) -> DynamicImage {
834
853
dynamic_map ! ( * self , ref p => imageops:: rotate270( p) )
835
854
}
0 commit comments