←Select platform

StampWidth Property

Summary
Gets and sets the width for the stamp image.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int StampWidth { get; set; } 
@property (nonatomic, assign) NSUInteger stampWidth; 
public int getStampWidth() 
public void setStampWidth(int value) 
public: 
property int StampWidth { 
   int get(); 
   void set (    int ); 
} 
StampWidth # get and set (CodecsWebpSaveOptions) 

Property Value

The default value is 0.

The width for the stamp image.

Remarks

The stamp is saved only if all the following are true:

If any of the above conditions are not met, the stamp is not saved.

The stamp size might be adjusted if CodecsSaveOptions.AdjustStampSize is set.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
using Leadtools.Pdf; 
 
public void TestSaveWebpExample() 
{ 
   // This example saves 3 files with various stamp settings and quality factors 
   string srcFile = Path.Combine(LEAD_VARS.ImagesDir, @"sample1.cmp"); 
   string dstFile = Path.Combine(LEAD_VARS.ImagesDir, @"out-"); 
 
   using (RasterCodecs codecs = new RasterCodecs()) 
   using (RasterImage image = codecs.Load(srcFile, 1)) 
   { 
      // CodecsWebpOptions & CodecsWebpSaveOptions reference 
      codecs.Options.Webp.Save.SaveWithStamp = true; 
      codecs.Options.Webp.Save.StampBitsPerPixel = 24; 
 
      codecs.Options.Webp.Save.QualityFactor = 20; 
      codecs.Options.Webp.Save.StampWidth = 160; 
      codecs.Options.Webp.Save.StampHeight = 120; 
      // this file should have a stamp that is 160x120 
      codecs.Save(image, dstFile + "stamp160x120-q20.webp", RasterImageFormat.Webp, 0); 
 
      // this file should have a stamp that is 240x200 
      codecs.Options.Webp.Save.QualityFactor = 120; 
      codecs.Options.Webp.Save.StampWidth = 240; 
      codecs.Options.Webp.Save.StampHeight = 200; 
      codecs.Save(image, dstFile + "stamp240x200-q120.webp", RasterImageFormat.Webp, 0); 
 
      // this file should have no stamp 
      codecs.Options.Webp.Save.SaveWithStamp = false; 
      codecs.Options.Webp.Save.QualityFactor = 0; 
      codecs.Save(image, dstFile + "NoStamp-lossless.webp", RasterImageFormat.Webp, 0); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.nio.file.Paths; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.MinMaxBitsCommand; 
 
 
// This example saves 3 files with various stamp settings and quality factors 
public void codecsWebpSaveWithStampExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String srcFile = combine(LEAD_VARS_IMAGES_DIR, "sample1.cmp"); 
   String dstFile = combine(LEAD_VARS_IMAGES_DIR, "out.webp"); 
 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.load(srcFile, 1); 
 
   // CodecsWebpOptions & CodecsWebpSaveOptions reference 
   codecs.getOptions().getWebp().getSave().setSaveWithStamp(true); 
   codecs.getOptions().getWebp().getSave().setStampBitsPerPixel(24); 
 
   codecs.getOptions().getWebp().getSave().setQualityFactor(20); 
   codecs.getOptions().getWebp().getSave().setStampWidth(160); 
   codecs.getOptions().getWebp().getSave().setStampHeight(120); 
   // this file should gethave() geta st()asetmp that is 160x120 
   codecs.save(image, dstFile + "stamp160x120-q20.webp", RasterImageFormat.WEBP, 0); 
 
   assertTrue("File unsuccessfully saved to " + dstFile + "stamp160x120-q20.webp", 
         (new File(dstFile + "stamp160x120-q20.webp")).exists()); 
   System.out.printf("File successfully saved to %s%n", dstFile + "stamp160x120-q20.webp"); 
 
   // this file should gethave() geta st()asetmp that is 240x200 
   codecs.getOptions().getWebp().getSave().setQualityFactor(120); 
   codecs.getOptions().getWebp().getSave().setStampWidth(240); 
   codecs.getOptions().getWebp().getSave().setStampHeight(200); 
   codecs.save(image, dstFile + "stamp240x200-q120.webp", RasterImageFormat.WEBP, 0); 
 
   assertTrue("File unsuccessfully saved to " + dstFile + "stamp240x200-q120.webp", 
         (new File(dstFile + "stamp240x200-q120.webp")).exists()); 
   System.out.printf("File successfully saved to %s%n", dstFile + "stamp240x200-q120.webp"); 
 
   // this file should have no stamp 
   codecs.getOptions().getWebp().getSave().setSaveWithStamp(false); 
   codecs.getOptions().getWebp().getSave().setQualityFactor(0); 
   codecs.save(image, dstFile + "NoStamp-lossless.webp", RasterImageFormat.WEBP, 0); 
 
   assertTrue("File unsuccessfully saved to " + dstFile + "NoStamp-lossless.webp", 
         (new File(dstFile + "NoStamp-lossless.webp")).exists()); 
   System.out.printf("File successfully saved to %s%n", dstFile + "NoStamp-lossless.webp"); 
 
   image.dispose(); 
   codecs.dispose(); 
} 
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.

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.