Leadtools.ImageProcessing.SpecialEffects Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
IntelligentDownScaleCommand Class
See Also  Members   Example 
Leadtools.ImageProcessing.SpecialEffects Namespace : IntelligentDownScaleCommand Class



Automatically reduces image size while preserving important features. It can also remove or preserve certain objects chosen by the user without affecting the natural look of the image.

Syntax

Visual Basic (Declaration)  
Public Class IntelligentDownScaleCommand 
   Inherits RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage) Copy Code
Dim instance As IntelligentDownScaleCommand
C#  
public class IntelligentDownScaleCommand : RasterCommand, IRasterCommand  
C++/CLI  
public ref class IntelligentDownScaleCommand : public RasterCommand, IRasterCommand  

Example

Visual Basic Copy Code
Public Sub IntelligentDownScaleCommandExample()
' Load an image
RasterCodecs.Startup()
Dim Codecs As RasterCodecs = New RasterCodecs()
Codecs.ThrowExceptionsOnInvalidImages = True

Dim image As RasterImage = Codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path & "Sample3.jpg")

Dim Command As IntelligentDownScaleCommand = New IntelligentDownScaleCommand()
Command.DownScalingOrder = 1
Command.NewWidth = image.Width - 100
Command.NewHeight = image.Height
Command.UsePreserveObjectColor = False
Command.UseRemoveObjectColor = False

' Apply the intelligent downscale on the image.
Command.Run(image)
Codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path & "IntelligentDownScaleResult.jpg", RasterImageFormat.Jpeg, 24)

RasterCodecs.Shutdown()
   End Sub
C# Copy Code
public void IntelligentDownScaleCommandExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Sample3.jpg"); 
 
   IntelligentDownScaleCommand command = new IntelligentDownScaleCommand(); 
   command.DownScalingOrder = 1; 
   command.NewWidth = image.Width - 100; 
   command.NewHeight = image.Height; 
   command.UsePreserveObjectColor = false; 
   command.UseRemoveObjectColor = false; 
 
   // Apply the intelligent downscale on the image. 
   command.Run(image); 
   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IntelligentDownScaleResult.jpg", RasterImageFormat.Jpeg, 24); 
 
   RasterCodecs.Shutdown(); 
}

Remarks

  • Dark areas are sometimes affected during downscaling since they are considered unimportant. If dark objects are affected during downscaling, the user can apply a Negative effect to the image, apply downscaling, and then apply the Negative effect to the image again to get the colors of original image. Alternatively the user can apply a mask on dark objects to keep them from being affected.
  • Downscaling is limited on images that are too condensed or where the content layout prevents downscaling without harming important aspects of the image.
  • Downscaling using a mask is performed only on width dimension. If the user wants to downscale using a mask on height dimension, rotate the image, downscale it on width dimension and rotate to the original orientation.
  • The color of the area to be removed must be different than colors in the image.
  • The color of the area to be preserved must be different than the colors in the image and different from the color of the area to be removed.
  • If multiple remove objects exist, then all of them have to be the same color of the area being removed. This also applies to a color area that is being preserved.
  • If the user wants the resulting size of a removal to be equal to the original size, then the user has to set new width equal to image width. This does NOT apply to preserve area and does NOT apply to the upscaling process.
  • Sometimes, letting the program determine the resulting width does not totally delete the area to be removed, the user needs to pass a new width to the original image that is less than the width of the resulting image with remaining portions of the removed area. For instance, if the downscaled image still has few pixels of the remove area after downscaling and its width is 300, the user can redo the downscaling on the original image but with a new width of 290.
  • If mask has an area to be preserved and no area to be removed, then the user has to specify newWidth.
  • It’s recommended to draw the mask over the area to be removed from top to bottom of the image a little larger than the area to be removed. This does not always hold true but it’s a good practice to follow.
  • It’s also recommended to make the mask wide enough to force the downscaling to be only in the remove area. This does not always hold true but it’s a good practice to follow.
  • This command does not support signed data images.
  • This command does not support 32-bit grayscale images.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.SpecialEffects.IntelligentDownScaleCommand

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also