Saving 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 GIFimage 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

using (Signature signature = new Signature("sample.jpg"))
{
    QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith")
    {
        EncodeType = QRCodeTypes.QR, Left = 100, Top = 100
    };
    SaveOptions saveOptions;
    // create Bmp save options with advanced settings
    saveOptions = new BmpSaveOptions()
    {
        AddMissingExtenstion = true,
        Compression = BitmapCompression.Rgb,
        HorizontalResolution = 7,
        VerticalResolution = 7,
        BitsPerPixel = 16,
        OverwriteExistingFiles = true
    };
    // sign document to file
    signature.Sign("signedSample", signOptions, saveOptions);
}

Save signed image as GIF

using (Signature signature = new Signature("sample.jpg"))
{
    QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith")
    {
        EncodeType = QRCodeTypes.QR, Left = 100, Top = 100
    };
    SaveOptions saveOptions;
    // create Gif save options with advanced settings
    saveOptions = new GifSaveOptions()
    {
        AddMissingExtenstion = true,
        BackgroundColorIndex = 2,
        ColorResolution = 7,
        DoPaletteCorrection = true,
        HasTrailer = true,
        Interlaced = false,
        IsPaletteSorted = true,
        PixelAspectRatio = 24
    };
    // sign document to file
    signature.Sign("SignedSample", signOptions, saveOptions);
}

Save signed image as JPEG

using (Signature signature = new Signature("sample.jpg"))
{
    QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith")
    {
        EncodeType = QRCodeTypes.QR, Left = 100, Top = 100
    };
    SaveOptions saveOptions;
    // create Jpeg save options with advanced settings
    saveOptions = new JpegSaveOptions()
    {
        AddMissingExtenstion = true,
        BitsPerChannel = 8,
        ColorType = JpegCompressionColorMode.Rgb,
        Comment = "signed jpeg file",
        CompressionType = JpegCompressionMode.Lossless,
        Quality = 100,
        SampleRoundingMode = JpegRoundingMode.Extrapolate
    };
    // sign document to file
    signature.Sign("SignedSample", signOptions, saveOptions);
}

Save signed image as PNG

using (Signature signature = new Signature("sample.jpg"))
{
    QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith")
    {
        EncodeType = QRCodeTypes.QR, Left = 100, Top = 100
    };
    SaveOptions saveOptions;
    // create png save options with advanced settings
    saveOptions = new PngSaveOptions()
    {
        AddMissingExtenstion = true,
        BitDepth = 8,
        ColorType = PngColorType.Grayscale,
        CompressionLevel = 9,
        FilterType = PngFilterType.Adaptive,
        Progressive = true
    };
    // sign document to file
    signature.Sign("SignedSample", signOptions, saveOptions);
}

Save signed image as TIFF

using (Signature signature = new Signature("sample.jpg"))
{
    QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith")
    {
        EncodeType = QRCodeTypes.QR, Left = 100, Top = 100
    };
    SaveOptions saveOptions;
    // create tiff save options with advanced settings
    saveOptions = new TiffSaveOptions()
    {
        AddMissingExtenstion = true,
        ExpectedTiffFormat = TiffFormat.TiffNoCompressionBw
    };
    // sign document to file
    signature.Sign("SignedSample", signOptions, saveOptions);
}

More resources

GitHub Examples

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

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To generate image signatures and/or sign your files with them for free, you can use the Generate Image online app.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the other online apps from the GroupDocs.Signature App Product Family.