Save signed images with various output types

Signature class supports saving of Image signed documents with various image format types and extended options.

Following classes are inherited from base class SaveOptions and allows to specify additional output image format settings.

  • BmpSaveOptions class allows to save signed image document to BMP image format and setup additional options ( like compression, resolutions, bits per pixel etc);
  • GifSaveOptions class allows to save signed image document to **GIF **image format and setup additional options ( like compression, resolutions etc);
  • JpegSaveOptions class allows to save signed image document to JPEG image format and setup additional options ( like compression, resolutions, quality etc);
  • PngSaveOptions class allows to save signed image document to PNG image format and setup additional options ( like bit depth, color type, compression, filters etc);
  • TiffSaveOptions class allows to save signed image document to TIFF image format and setup additional options

Here are the steps to save signed Image document to special image output type with additional settings with GroupDocs.Signature:

Save signed image as BMP

Signature signature = new Signature("sample.jpg");
QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith");
signOptions.setEncodeType(QrCodeTypes.QR);
signOptions.setLeft(100);
signOptions.setTop(100);
 
// create Bmp save options with advanced settings
BmpSaveOptions bmpSaveOptions = new BmpSaveOptions();
bmpSaveOptions.setAddMissingExtenstion(true);
bmpSaveOptions.setCompression(BitmapCompression.Rgb);
bmpSaveOptions.setHorizontalResolution(7);
bmpSaveOptions.setVerticalResolution(7);
bmpSaveOptions.setBitsPerPixel(16);
bmpSaveOptions.setOverwriteExistingFiles(true);
 
signature.sign("signedSample", signOptions, bmpSaveOptions );

Save signed image as GIF

Signature signature = new Signature("sample.jpg");
QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith");
signOptions.setEncodeType(QrCodeTypes.QR);
signOptions.setLeft(100);
signOptions.setTop(100);
 
// create Gif save options with advanced settings
GifSaveOptions gifSaveOptions = new GifSaveOptions();
gifSaveOptions.setBackgroundColorIndex((byte)2);
gifSaveOptions.setColorResolution((byte) 7);
gifSaveOptions.setDoPaletteCorrection(true);
gifSaveOptions.setTrailer(true);
gifSaveOptions.setInterlaced(false);
gifSaveOptions.setPaletteSorted(true);
gifSaveOptions.setPixelAspectRatio((byte) 24);
gifSaveOptions.setAddMissingExtenstion(true);
 
 
signature.sign("signedSample", signOptions, bmpSaveOptions );

Save signed image as JPEG

Signature signature = new Signature("sample.jpg");
QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith");
signOptions.setEncodeType(QrCodeTypes.QR);
signOptions.setLeft(100);
signOptions.setTop(100);
 
// create Jpeg save options with advanced settings
JpegSaveOptions jpegSaveOptions = new JpegSaveOptions();
jpegSaveOptions.setAddMissingExtenstion(true);
jpegSaveOptions.setBitsPerChannel((byte) 8);
jpegSaveOptions.setColorType(JpegCompressionColorMode.Rgb);
jpegSaveOptions.setComment("signed jpeg file");
jpegSaveOptions.setCompressionType(JpegCompressionMode.Lossless);
jpegSaveOptions.setQuality(100);
jpegSaveOptions.setSampleRoundingMode(JpegRoundingMode.Extrapolate);
 
 
signature.sign("signedSample", signOptions, jpegSaveOptions);

Save signed image as PNG

Signature signature = new Signature("sample.jpg");
QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith");
signOptions.setEncodeType(QrCodeTypes.QR);
signOptions.setLeft(100);
signOptions.setTop(100);
 
// create png save options with advanced settings
PngSaveOptions pngSaveOptions = new PngSaveOptions();
pngSaveOptions.setBitDepth((byte) 8);
pngSaveOptions.setColorType(PngColorType.Grayscale);
pngSaveOptions.setCompressionLevel(9);
pngSaveOptions.setFilterType(PngFilterType.Adaptive);
pngSaveOptions.setProgressive(true);
pngSaveOptions.setAddMissingExtenstion(true);
 
 
signature.sign("signedSample", signOptions, pngSaveOptions );

Save signed image as TIFF

Signature signature = new Signature("sample.jpg");
QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith");
signOptions.setEncodeType(QrCodeTypes.QR);
signOptions.setLeft(100);
signOptions.setTop(100);
 
/// create tiff save options with advanced settings
TiffSaveOptions tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.setExpectedTiffFormat(TiffFormat.TiffNoCompressionBw);
tiffSaveOptions.setAddMissingExtenstion(true);
 
 
signature.sign("signedSample", signOptions, tiffSaveOptions  );

More resources

GitHub Examples 

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App 

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.

© Aspose Pty Ltd 2001-2022. All Rights Reserved.