Links

Get image metadata for uploaded media files

You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.
💡
You can also get the file metadata while uploading the file by passing metadata in responseFields parameter.
get
https://api.imagekit.io
/v1/files/:fileId/metadata
Get file metadata for uploaded media files API

Response structure and status code (application/JSON)

In case of error, you will get an error code along with the error message. On success, you will receive a 200 status code with the image metadata in the JSON-encoded response body.
A metadata object example can be found here.

Examples

Here are some example requests to understand the API usage.

Get metadata of an uploaded file

cURL
Node.js
Python
PHP
Java
Ruby
Go
.Net
# The unique fileId of the uploaded file. fileId is returned in response of list files API and upload API.
curl -X GET "https://api.imagekit.io/v1/files/file_id/metadata" \
-u your_private_api_key:
var ImageKit = require("imagekit");
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
imagekit.getFileMetadata("file_id", function(error, result) {
if(error) console.log(error);
else console.log(result);
});
from imagekitio import ImageKit
imagekit = ImageKit(
public_key='your_public_api_key',
private_key='your_private_api_key',
url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
)
metadata = imagekit.get_metadata(file_id="file_id")
print("File detail-", metadata, end="\n\n")
# Raw Response
print(metadata.response_metadata.raw)
# print the file metadata fields
print(metadata.width)
print(metadata.exif.image.x_resolution)
# Raw Response
print(metadata.response_metadata.raw)
# print the file metadata fields
print(metadata.width)
print(metadata.exif.image.x_resolution)
use ImageKit\ImageKit;
$public_key = "your_public_api_key";
$your_private_key = "your_private_api_key";
$url_end_point = "https://ik.imagekit.io/your_imagekit_id";
$imageKit = new ImageKit(
$public_key,
$your_private_key,
$url_end_point
);
$fileId = 'file_id';
$fileMetadata = $imageKit->getFileMetaData($fileId);
echo("File metadata : " . json_encode($fileMetadata));
ResultMetaData result=ImageKit.getInstance().getFileMetadata("file_id");
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
file_metadata = imagekitio.get_file_metadata(file_id: "file_id")
resp, err := ik.Metadata.FromFile(ctx, "file_id")
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
ResultMetaData resultMetaData = imagekit.GetFileMetadata("file_id");

Calculate pHash distance between two images

See examples here.