Imaging.Net - adding signature to image

Hi, I’m evaluating Aspose.Imaging for .NET for adding signatures to tiff files stored in a database. The source document is already loaded in a Dynamsoft.ImageCore which allows me to access a single page as a System.Drawing.Bitmap. Unfortunately, Aspose.Imaging only supports opening files or IO streams. The signature comes from a binary field in a database and is returned as a byte array. This is not supported by Aspose.Imaging either. My code is below:

Dim original1stpagebm As System.Drawing.Bitmap = materialsfrm.m_ImageCore.ImageBuffer.GetBitmap(index)
'Load into an IO stream
Dim ms As New MemoryStream
original1stpagebm.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff)
ms.Seek(0, 0)
Dim original1stpage As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(ms)
'Get signature from DB as byte array
materialsfrm.ADOCmdMiscSelects.Parameters("@p_op").Value = "GETSIG"
materialsfrm.ADOCmdMiscSelects.Parameters("@p_misc_code").Value = "abarrett"
Dim rs As SqlDataReader = materialsfrm.ADOCmdMiscSelects.ExecuteReader()
Dim ContractManagerSignaturebaor() As Byte = rs("manager_signature")
Dim ContractManagerSignatureWidth As Decimal = rs("signature_width")
Dim ContractManagerSignatureHeight As Decimal = rs("signature_height")
Dim signature As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(New MemoryStream(ContractManagerSignaturebaor))
Dim graphics As New Aspose.Imaging.Graphics(original1stpage)
graphics.DrawImage(signature, New Aspose.Imaging.Point(original1stpage.Height - signature.Height, original1stpage.Width - signature.Width))
Dim ms2 As New MemoryStream
ms2.Seek(0, 0)
'Push the updated page back to the ImageCore
materialsfrm.m_ImageCore.ImageBuffer.SetBitmap(index, New Bitmap(ms2))

the resulting page does not show the signature. I know that the signature is OK since I use the very same one in another module when inserting into an Aspose.Words document as follows:

Dim image As Aspose.Words.Drawing.Shape = builder.InsertImage(ContractManagerSignaturebaor)

Luckily, Aspose.Words does accept a byte array directly.

Do you have any ideas why the signature does not get imprinted on the source image please?

Thank you very much


Usually, signing is not a part of image formats specifications. However, it can be done indirectly for image and for any other file. We have another product which could help. You can please check the following link and contact further with GroupDocs support in case there is an issue.

Thank you, but I’m simply trying to place an image containing a signature on the 1st page of a TIFF file, so it is not signing the document as such. Thanks


Can you please check this documentation link for your kind reference. As far as your requirement of signature image stored in database in the form of some byte array, you can extract the byte array image, convert that to stream and then use API to load that. I hope the shared elaboration will be helpful.

Lastly, the issue may be by use of Dynamsoft and we may not be able to investigate that. As far as Aspose.Imaging, API is concerned, I have shared above the documentation link adding signature to Tiff. If you still find issue then please share the source TIff file, source signature image and desired Tiff file. We will try to investigate that further on our end only using Aspose.Imaging API.

Aspose.Imaging working (463.1 KB)
Thank you. My code was taken from the documentation that you have given a link for. I don’t think it is the Dynamsoft object that is the problem since drawing text using your example works fine. It is only the rastorising of an image onto the source image that doesn’t seem to work. I have discovered that the signature is in a BMP indexed format, but even using a PNG makes no difference. What is the most elegant solution for:

  1. Converting a byte array into a format suitable for Aspose.Imaging
  2. Converting a System.Drawing.Bitmap into a format suitable for Aspose.Imaging

I have attached the images as requested. Thank you


The Stream class allows importing ByteArray to form a stream.

byte[] file = File.ReadAllBytes("{FilePath}");  
Stream stream = new MemoryStream(file); 

Aspose.Imaging, provides Load overloads methods for loading images in application. You can please visit this API reference guide link for your convenience. There is no direct loading of System.Drawing.Bitmap in Image.Load().

Thank you, but that is really no help at all! Why does Aspose.Words support the direct loading from a byte array but Apose.Imaging does not? Why is there an assumption that images are going to loaded from disk all the time?
Please can you give the most elegant code (by that I mean least RAM impact and requiring the least intermediate declarations) to load a bytearray into Aspose.Imaging and the same for loading an existing bitmap into an Aspose.Imaging. Thank you
Did you discover why the signature image does not seem to rastorise onto the main image?

Can I buy support then before buying Aspose.Imaging so that I can find out of it will work before buying? I got my fingers burnt when buying Aspose.PDF that had bugs with extracting images from non standard page sizes that were never resolved as far as I know! It seems that no paid support = no interest in any limitations/bugs discovered from people with no paid support?


We appreciate your interest in API. We need to further investigate the requirements internally on our end. I have created a ticket with ID IMAGINGNET-4305 in our issue tracking system to further investigate this on our end and get back to you with feedback as soon as it will be addressed.


Can you please consider swapping the coordinates in following line and share your kind feedback.

graphics.DrawImage(signature, New Aspose.Imaging.Point(original1stpage.Width - signature.Width, original1stpage.Height - signature.Height))

I hope the suggested solution shall work on your end.

Thank you, that worked. Great!
I would still appreciate your help in how to format a cleaner way to convert a byte array into Aspose.Imaging preferably entirely within the Aspose.load statement and the same for loading a bitmap. Having to create a memory stream and reset the starting position seems long winded. Also a similar way to save from Apose.Imaging directly to a byte array or bitmap. I do appreciate that Apose.Imaging does not support these formats, but example code that would allow this neatly would be excellent. I use VB but c# example would also be OK.
Thank you very much

I’ve just ordered and paid for a license, thank you

I have added a new ticket with ID IMAGINGNET-4311 in our issue tracking system to further investigate if we can provide provision of directly loading the Byte Array in Image.Load() method rather converting byte array to stream and then loading that. The ticket also cover the investigation of provision of loading Bitmap object using API. We will share the feedback with you as soon as it will be shared.


We have investigated requirements on our end and are not going to support GDI+ specific overloads in our library, because Aspose.Imaging is graphics library and we are not interested to reference inside library to another libraries. But there exist some solutions that you may try to implement on your end.

  1. As you know Imaging has Image, RasterImage classes hierarchy not sealed, so you can easily inherit your own class from this and add needed function.

  2. You can also consider using extension methods. ie.

         public void Draw(this Aspose.Imaging.Image image)
             Graphics graphics = new Graphics(image);
             graphics.DrawImage(signature, New Aspose.Imaging.Point(original1stpage.Width - signature.Width, original1stpage.Height - signature.Height));

We do not plan to support such reload as it is obvious for Aspose.Imaging due to described reasons.

Thank you for investigating this. Does this mean that Aspose.Cells, Aspose.Words and Aspose.PDF do reference GDI+ then? Does this make the Aspose.Imaging more portable that these libraries then?


I may request you to please consult Aspose.Total support forum for this. I am moving this thread to Aspose.Total forum where our team will assist you further.


As far as Aspose.Cells and Aspose.PDF are concerned, they do reference GDI+. However, in case of Aspose.Words, it does not use native libraries directly. Aspose.Words if used in .NET Framework refers to System.Drawing which will internally use Windows GDI/GDI+ libraries.