←Select platform

Options Property

Summary
Gets or sets the options used when optimizing the image specified in InputFileName.

Syntax
C#
C++/CLI
Python
public ImageOptimizerOptions Options { get; set; } 
public: 
property ImageOptimizerOptions Options { 
   ImageOptimizerOptions get(); 
   void set (    ImageOptimizerOptions ); 
} 
Options # get and set (ImageOptimizerDirectoryData) 

Property Value

The options used when optimizing the image specified in InputFileName.

Remarks

You can update the optimization options only if the Status property is set to ImageOptimizerDirectoryStatus.PreOptimizingImage.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageOptimization; 
 
 
int _imageNo; 
 
public void TestDirImageOptimizer() 
{ 
   _imageNo = 0; 
 
   // Initialize the RasterCodecs class 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // The input and output directories 
   string inputDirectory = LEAD_VARS.ImagesDir; 
   string outputDirectory = Path.Combine(LEAD_VARS.ImagesDir, "OptimizedImages"); 
 
   // Initialize a new Optimizer object 
   ImageOptimizer optimizer = new ImageOptimizer(); 
 
   // Optimization Options 
   ImageOptimizerOptions options = ImageOptimizerOptions.Default; 
 
   optimizer.OptimizeDirectory(codecs, 
      inputDirectory, 
      outputDirectory, 
      options, 
      "*.jpg", 
      false, 
      ImageOptimizerDirectory); 
 
   //shutdown the RasterCodecs class. 
} 
 
bool ImageOptimizerDirectory(ImageOptimizerDirectoryData data) 
{ 
   Console.WriteLine(string.Format("File Percent = {0}%,    Total Percent = {1}%", data.FilePercent, data.TotalPercent)); 
 
   if (_imageNo == data.TotalFolderFilesCount) 
   { 
      // Operation Done. 
      Console.WriteLine("Optimization Operation Completed Successfully"); 
      return true; 
   } 
   else if (data.Status == ImageOptimizerDirectoryStatus.PreOptimizingImage) 
   { 
      string text = string.Format("Optimizing Image {0} ?\n", data.InputFileName); 
      DialogResult result = MessageBox.Show(text, "", MessageBoxButtons.YesNoCancel); 
 
      if (result == DialogResult.Yes) 
      { 
         // Optimize the image using the default options. 
         data.Options = ImageOptimizerOptions.Default; 
         return true; 
      } 
      else if (result == DialogResult.No) 
      { 
         // Skip this image. 
         _imageNo++; 
         data.SkipImage = true; 
      } 
      else 
         // Stop the whole operation. 
         return false; 
   } 
   else if (data.FilePercent == 100) 
   { 
      _imageNo++; 
 
      // Displaying information about the optimized image. 
      string msg = string.Format("Optimizing File ( {0} of {1} ) \n" + 
         "--------------------------------\n" + 
         "Source File Name = {2}\n" + 
         "Detination File Name = {3}\n" + 
         "No of Pages = {4}\n", 
         _imageNo, data.TotalFolderFilesCount, data.InputFileName, data.OutputFileName, data.ImageInfo.TotalPages); 
 
      Console.WriteLine(msg); 
   } 
   return true; 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.