How to Get Image Information in C/C++

Retrieving details from images can provide valuable insight into image standards, processing, and more. However, it’s not always the easiest task to accomplish. To simplify the extraction of information from an image, you can use the following API in C/C++ to perform the task in seconds.

First, we will install libcurl into our project:


With the installation out of the way, we are ready to input the image file and call the function:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "inputFile");
curl_mime_filedata(part, "/path/to/file");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);

After the request is sent to the server, a wide range of information will be returned; the below snapshot provides a complete summary of the extracted details:

"Successful": true,
"ColorSpace": "string",
"ColorType": "string",
"Width": 0,
"Height": 0,
"CompressionLevel": 0,
"ImageHashSignature": "string",
"HasTransparency": true,

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.