@@ -1513,6 +1513,21 @@ public void ClipOutside(string pathName)
15131513 public IMagickImage < QuantumType > Clone ( )
15141514 => new MagickImage ( this ) ;
15151515
1516+ /// <summary>
1517+ /// Creates a clone of the current image and executes the action that can be used
1518+ /// to mutate the clone. This is more efficient because it prevents an extra copy
1519+ /// of the image.
1520+ /// </summary>
1521+ /// <param name="action">The mutate action to execute on the clone.</param>
1522+ /// <returns>A clone of the current image.</returns>
1523+ public IMagickImage < QuantumType > CloneAndMutate ( Action < IMagickImageCloneMutator > action )
1524+ {
1525+ using var imageCreator = new CloneMutator ( _nativeInstance ) ;
1526+ action ( imageCreator ) ;
1527+
1528+ return Create ( imageCreator . GetResult ( ) , _settings ) ;
1529+ }
1530+
15161531 /// <summary>
15171532 /// Creates a clone of the current image with the specified geometry.
15181533 /// </summary>
@@ -5206,7 +5221,10 @@ public void ResetPage()
52065221 /// <param name="height">The new height.</param>
52075222 /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
52085223 public void Resize ( uint width , uint height )
5209- => Resize ( new MagickGeometry ( width , height ) ) ;
5224+ {
5225+ using var mutator = new Mutater ( _nativeInstance ) ;
5226+ mutator . Resize ( width , height ) ;
5227+ }
52105228
52115229 /// <summary>
52125230 /// Resize image to specified geometry.
@@ -5215,9 +5233,8 @@ public void Resize(uint width, uint height)
52155233 /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
52165234 public void Resize ( IMagickGeometry geometry )
52175235 {
5218- Throw . IfNull ( nameof ( geometry ) , geometry ) ;
5219-
5220- _nativeInstance . Resize ( geometry . ToString ( ) ) ;
5236+ using var mutator = new Mutater ( _nativeInstance ) ;
5237+ mutator . Resize ( geometry ) ;
52215238 }
52225239
52235240 /// <summary>
@@ -5226,7 +5243,10 @@ public void Resize(IMagickGeometry geometry)
52265243 /// <param name="percentage">The percentage.</param>
52275244 /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
52285245 public void Resize ( Percentage percentage )
5229- => Resize ( new MagickGeometry ( percentage , percentage ) ) ;
5246+ {
5247+ using var mutator = new Mutater ( _nativeInstance ) ;
5248+ mutator . Resize ( percentage ) ;
5249+ }
52305250
52315251 /// <summary>
52325252 /// Resize image to specified percentage.
@@ -5235,7 +5255,10 @@ public void Resize(Percentage percentage)
52355255 /// <param name="percentageHeight">The percentage of the height.</param>
52365256 /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
52375257 public void Resize ( Percentage percentageWidth , Percentage percentageHeight )
5238- => Resize ( new MagickGeometry ( percentageWidth , percentageHeight ) ) ;
5258+ {
5259+ using var mutator = new Mutater ( _nativeInstance ) ;
5260+ mutator . Resize ( percentageWidth , percentageHeight ) ;
5261+ }
52395262
52405263 /// <summary>
52415264 /// Roll image (rolls image vertically and horizontally).
0 commit comments