eSign image with Digital signature

What is an Image Digital Signature?

An Image Digital Signature uses steganography (LSB - Least Significant Bit technique) to embed digital signatures directly into raster image pixels. This method allows you to add invisible, password-protected signatures to images while maintaining image quality. The signature data is embedded into the least significant bits of image pixels, making the signature undetectable to the naked eye.

Key Features

  • Invisible Signatures: Signatures are embedded directly into image pixels using steganography
  • Password Protection: Signatures are protected with a password (minimum 4 characters)
  • Format Support: Works with PNG and JPG image formats
  • Quality Preservation: Image quality remains virtually unchanged
  • Size Requirements: Images must meet minimum size requirements (8x8 pixels, 16,384 total pixels)

Requirements

Image Size Requirements

  • Minimum Width: 8 pixels
  • Minimum Height: 8 pixels
  • Minimum Total Pixels: 16,384 pixels (width × height)

Password Requirements

  • Minimum Length: 4 characters
  • Case Sensitive: Yes
  • Special Characters: Allowed

Supported Formats

  • PNG - Fully supported
  • JPG/JPEG - Fully supported
  • BMP - Not supported for digital steganography signatures

How to eSign image with Digital signature

GroupDocs.Signature provides the ImageDigitalSignOptions class to specify settings for digital signatures in images using steganography.

Here are the steps to sign an image with a digital signature:

This example shows how to sign an image with a digital signature using steganography.

using (Signature signature = new Signature("image.png"))
{
    // Create sign options with password
    ImageDigitalSignOptions signOptions = new ImageDigitalSignOptions
    {
        Password = "MySecurePassword123"
    };

    // Sign the image
    SignResult signResult = signature.Sign("signed_image.png", signOptions);
    
    Console.WriteLine($"Image signed successfully. Found {signResult.Succeeded.Count} signatures.");
}

Signing Images from Streams

You can also sign images using streams instead of file paths:

using (Stream inputStream = new FileStream("image.png", FileMode.Open, FileAccess.Read))
using (Signature signature = new Signature(inputStream))
{
    ImageDigitalSignOptions signOptions = new ImageDigitalSignOptions
    {
        Password = "MySecurePassword123"
    };

    using (Stream outputStream = new FileStream("signed_image.png", FileMode.Create))
    {
        SignResult signResult = signature.Sign(outputStream, signOptions);
        Console.WriteLine($"Signed: {signResult.Succeeded.Count} signature(s) added.");
    }
}

Error Handling

The library automatically validates password length and image size requirements. Handle exceptions appropriately:

try
{
    using (Signature signature = new Signature("image.png"))
    {
        ImageDigitalSignOptions signOptions = new ImageDigitalSignOptions
        {
            Password = "MyPassword123"  // Minimum 4 characters required
        };

        SignResult signResult = signature.Sign("signed_image.png", signOptions);
        Console.WriteLine("✓ Image signed successfully!");
    }
}
catch (ArgumentException ex)
{
    Console.WriteLine($"Password validation error: {ex.Message}");
    // Password must be at least 4 characters long
}
catch (InvalidOperationException ex)
{
    Console.WriteLine($"Image size error: {ex.Message}");
    // Image is too small for digital steganography signature
}

Limitations and Considerations

Format Limitations

  • PNG: Fully supported ✅
  • JPG/JPEG: Fully supported ✅
  • BMP: Not supported ❌
  • Other formats: Not supported ❌

Image Size Limitations

  • Images smaller than 8x8 pixels cannot be signed
  • Images with fewer than 16,384 pixels cannot be signed

Steganography Considerations

  • Image compression (especially JPG) may affect signature detection
  • Image editing may corrupt embedded signatures
  • Always keep original signed images for verification
  • The signature is embedded invisibly in the image pixels

Summary

This guide demonstrates how to use GroupDocs.Signature to sign images with digital signatures using steganography. It covers loading images, configuring password-protected digital signatures that are embedded invisibly into image pixels, and saving signed images. The feature provides invisible authentication while maintaining image quality and requires minimum size requirements for images.

Advanced Usage Topics

To learn more about document eSign features, please refer to the advanced usage section.

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 sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.