Last updated on April 20, 2021 by Muzammil Khan
Blog Home

Extract and Manipulate Metadata of Images using C#

Share on Facebook
Facebook
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Extract Metadata from Images using C#

You can add, edit, remove or extract image details such as height, width, make, model, etc. stored in the form of metadata programmatically. As a C# developer, you can easily extract and manipulate the metadata information of images programmatically on the cloud. In this article, you will learnĀ how to extract and manipulate the metadata of images using a REST API in C#.

The following topics are discussed/covered in this article:

  • Document Metadata Manipulation REST API and .NET SDK
  • Add Metadata to Images using a REST API
  • Update Metadata of Image using a REST API
  • Remove Metadata from Images using a REST API
  • Extract Metadata from Images using a REST API

Document Metadata Manipulation REST API and .NET SDK

For manipulating the metadata of JPEG images, I will be using the .NET SDK of GroupDocs.Metadata Cloud API. It allows you to add, edit, retrieve, and remove metadata properties from documents and image file formats. You just need to define the search criteria and the metadata Cloud REST API will take care of the specified metadata operations within supported file formats. It also provides Java SDK as its document metadata manipulation family members for the Cloud API.

You can install GroupDocs.Metadata to your Visual Studio project from the NuGet Package Manager or using the following command in the Package Manager console:

Install-Package GroupDocs.Metadata-Cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your client ID and Secret, add in the code as shown below:

Add Metadata to Images using a REST API in C#

You can add metadata to images by following the simple steps given below:

  • Upload the image to the Cloud
  • Add Metadata to Image using C#
  • Download the updated image

Upload the Image

Firstly, upload the JPEG file on the Cloud using the code sample given below:

As a result, the uploaded JPEG image file will be available in the files section of your dashboard on the cloud.

Add Metadata to Image using C#

You can add metadata to the JPEG image programmatically by following the steps given below.

  • Create an instance of MetadataApi
  • Set the JPEG image file path in the FileInfo model
  • Define AddOptions
  • Set Value and SearchCriteria for the property using the AddProperty model
  • Create AddRequest with AddOptions
  • Get results by calling the MetadataApi.Add() method

The following code sample shows how to add metadata to a JPEG image using a REST API.

Add Metadata from Images using a REST API in C#
Add Metadata from Images using a REST API in C#

Download the Image

The above code samples will save the updated JPEG file on the cloud and can be downloaded using the following code sample:

Update Metadata of Image using C#

You can update the metadata of the JPEG image programmatically by following the steps given below.

  • Create an instance of MetadataApi
  • Set the JPEG image file path in the FileInfo model
  • Define the SetOptions
  • Set NewValue and SearchCriteria for the property using the SetProperty model
  • Create SetRequest with SetOptions
  • Get results by calling the MetadataApi.Set() method

The following code sample shows how to set metadata of a JPEG image using a REST API. Please follow the steps mentioned earlier to upload and download a file.

Update Metadata from Images using a REST API in C#
Update Metadata from Images using a REST API in C#

Remove Metadata from Image using C#

You can remove metadata from the JPEG image programmatically by following the steps given below.

  • Create an instance of MetadataApi
  • Set the JPEG image file path in the FileInfo model
  • Define RemoveOptions
  • Set the search criteria
  • Create RemoveRequest with RemoveOptions
  • Get results by calling the MetadataApi.Remove() method

The following code sample shows how to remove metadata from a JPEG image using a REST API. Please follow the steps mentioned earlier to upload and download a file.

Remove Metadata from Images using a REST API in C#
Remove Metadata from Images using a REST API in C#

Extract Metadata from Image using C#

You can extract the metadata from the JPEG image programmatically by following the steps given below.

  • Create an instance of MetadataApi
  • Set the JPEG image file path in the FileInfo model
  • Define ExtractOptions
  • Create ExtractRequest with ExtractOptions
  • Get results by calling the MetadataApi.Extract() method

The following code sample shows how to extract metadata from a JPEG image using a REST API. Please follow the steps mentioned earlier to upload a file.

Image Metadata
Image Metadata

The above code sample will produce the following output:

Package: FileFormat
FileFormat : 9
MimeType : image/jpeg
ByteOrder : 1
Width : 480
Height : 360

Package: Xmp
http://ns.microsoft.com/photo/1.0/ :

Package: Exif
Exif.GpsIfd :
Exif.ExifIfd :
Make : Canon
Model : Canon PowerShot S40
Orientation : System.Int32[]
XResolution : System.Double[]
YResolution : System.Double[]
ResolutionUnit : System.Int32[]
DateTime : 2003:12:14 12:01:44
YCbCrPositioning : System.Int32[]
ExifIfd : System.Int64[]
Exif.Thumbnail : System.Byte[]

Try Online

Please try the following JPEG Metadata manipulation free online tool, which is developed using the above API. https://products.groupdocs.app/metadata/jpeg

Conclusion

In this article, you have learned how to add, edit, remove and extract Metadata from images on the cloud. This article also explained how to programmatically upload a JPEG image file on the cloud and download it from the cloud. You can learn even more about GroupDocs.Metadata Manipulation Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also

  • Edit Metadata of PDF Files using a REST API in C#
  • Manage Metadata of Documents using Java & .NET | Metadata Cloud API
  • Manage Metadata of Documents using Java & .NET

This entry was posted in GroupDocs.Metadata Cloud Product Family and tagged add metadata, Add Metadata to Images, extract metadata, Extract Metadata from Images, Extract Metadata from JPEG, Extract Metadata using C#, Remove Metadata of Images, Update Metadata of Images. .

← Remove Signatures from Signed PDF Document using Python
Extract Specific Data from PDF using Python →
  • Search

  • Follow Us

    RSS Facebook Twitter YouTube LinkedIn

  • Categories

    • GroupDocs.Total Cloud Product Family
      (3)
    • GroupDocs.Viewer Cloud Product Family
      (22)
    • GroupDocs.Annotation Cloud Product Family
      (16)
    • GroupDocs.Conversion Cloud Product Family
      (140)
    • GroupDocs.Comparison Cloud Product Family
      (13)
    • GroupDocs.Signature Cloud Product Family
      (16)
    • GroupDocs.Metadata Cloud Product Family
      (4)
    • GroupDocs.Parser Cloud Product Family
      (16)
    • GroupDocs.Watermark Cloud Product Family
      (4)
    • GroupDocs.Editor Cloud Product Family
      (7)
    • GroupDocs.Merger Cloud Product Family
      (54)
    • GroupDocs.Classification Cloud Product Family
      (5)
    • GroupDocs.Translation Cloud Product Family
      (1)
    • GroupDocs.Assembly Cloud Product Family
      (0)
    • GroupDocs.Rewriter Cloud Product Family
      (0)
    • News Release
      (0)