Annotate JPG Images using C#

annotate jpg images using C#

You can annotate images of popular image formats such as JPEG, PNG, TIFF programmatically. Annotations on the images provide additional information about an existing piece of data. You can add a wide range of graphic, text, and watermark annotations to images in your .NET applications. In this article, you will learn how to annotate JPG images using C#.

The following topics are discussed/covered in this article:

C# API to Annotate Images

For annotating JPG images, I will be using GroupDocs.Annotation for .NET API. It allows to programmatically build document annotation applications in C#, ASP.NET, and other related .NET technologies. You can add popular annotation types such as area, point, text, ellipse, link, underline, polyline, arrow, distance, watermark, image, etc to your documents of all popular formats. The API also enables you to export documents after adding annotations, comments, or highlighted notes back to their original format.

You can either download the DLL of the API or install it using NuGet.

Install-Package GroupDocs.Annotation

Annotate JPG Images using C#

You can add multiple annotations to annotate your JPG images by following the steps given below:.

  • Create an instance of the Annotator class
  • Provide the input file path
  • Create an instance of the ArrowAnnotation class
  • Set various properties for ArrowAnnotation such as Color, Opacity, Style etc.
  • Add ArrowAnnotation to Annotations List
  • Create an instance of the DistanceAnnotation class
  • Set various properties for DistanceAnnotation such as Color, Opacity, Style etc.
  • Add DistanceAnnotation to Annotations List
  • Create an instance of the EllipseAnnotation class
  • Set various properties for EllipseAnnotation such as Color, Opacity, Style etc.
  • Add EllipseAnnotation to Annotations List
  • Create an instance of the PointAnnotation class
  • Set various properties for PointAnnotation such as box size and location
  • Add PointAnnotation to Annotations List
  • Call the Add() method to add annotations to the Annotator
  • Call the Save() method and save the resultant file

The following code sample shows how to annotate a JPG image using C#.

Annotate JPG Images using C#
Annotate JPG Images using C#

The Annotator class is the main class that controls the document annotating process. It provides various methods to add, update or remove annotations. The Save() method of this class saves the annotated file at the given path.

The API provides various specific classes to define various types of annotations such as:

  • The ArrowAnnotation class provides properties to define arrow annotation
  • The DistanceAnnotation class facilities to define distance annotation
  • The EllipseAnnotation class can be used to define an Ellipse annotation
  • The PointAnnotation class provides properties to define a point annotation

Add Area Annotation to JPG using C#

You can add area annotation to your JPG images programmatically by following the steps given below:.

  • Create an instance of the Annotator class
  • Provide the input file path
  • Create an instance of the AreaAnnotation class
  • Set various properties for AreaAnnotation such as Position, Color, Message, Opacity, Style etc.
  • Call the Add() method to add AreaAnnotation to the Annotator
  • Call the Save() method and save the resultant file

The following code sample shows how to add area annotation to a JPG image using C#.

Add Area Annotation to JPG using C#
Add Area Annotation to JPG using C#

Add Text Field Annotation to JPG using C#

You can add text field annotation to your JPG images by following the steps given below:.

  • Create an instance of the Annotator class
  • Provide the input file path
  • Create an instance of the TextFieldAnnotation class
  • Set various properties for TextFieldAnnotation such as Text, Color, Opacity, Style, Font, etc.
  • Call the Add() method to add TextFieldAnnotation to the Annotator
  • Call the Save() method and save the resultant file

The following code sample shows how to add text field annotation to a JPG image using C#.

Add Text Field Annotation to JPG using C#
Add Text Field Annotation to JPG using C#

Annotation JPG Images with Watermark using C#

You can annotate your JPG images with watermark text by following the steps given below:.

  • Create an instance of the Annotator class
  • Provide the input file path
  • Create an instance of WatermarkAnnotation class
  • Set various properties for WatermarkAnnotation such as Text, Color, Font Size, Alignment, etc.
  • Call the Add() method to add WatermarkAnnotation to the Annotator
  • Call the Save() method and save the resultant file

The following code sample shows how to annotate a JPG image with watermark text using C#.

Annotation Images with Watermark
Annotation JPG Images with Watermark using C#

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, you have learned how to annotate JPG images using C#. You have also learned how to add multiple annotations to JPG images. Moreover, you have learned how to add area, text field, and watermark annotations to the JPG images programmatically in C#. You can learn more about GroupDocs.Annotation for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also