Links

Get image metadata from remote URL

get
https://api.imagekit.io
/v1/metadata
Get image metadata from remote URL 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.

Metadata through ImageKit transformation URL

If the url passed to this API has no transformation parameter, then the metadata of the original uploaded image will be fetched. We internally add orig-true parameter to fetch the original image.
Instead, if the passed url has any transformation parameters, then the metadata of the transformed image will be fetched.
See the examples below.

Examples

Here are some example requests to understand the API usage.

Get metadata of an original image (no transformation applied)

cURL
Python
PHP
Java
Ruby
Go
# 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/metadata?url=https://ik.imagekit.io/demo/default-image.jpg" \
-u your_private_api_key:
get_metadata = imagekit.get_remote_file_url_metadata(remote_file_url="remote_file_url")
​
print(get_metadata, end="\n\n")
​
# Raw Response
print(get_metadata.response_metadata.raw)
​
# print the file metadata fields
print(get_metadata.width)
print(get_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
);
​
$fileMetadata = $imageKit->getFileMetadataFromRemoteURL("https://ik.imagekit.io/demo/tr:w-100/default-image.jpg")
​
echo("File metadata : " . json_encode($fileMetadata));
ResultMetaData result=ImageKit.getInstance().getRemoteFileMetadata("remote_file_url");
imagekitio = ImageKit::ImageKitClient.new("your_private_key", "your_public_key", "your_url_endpoint")
imagekitio.get_remote_file_url_metadata("remote_file_url")
resp, err := ik.Metadata.FromUrl(ctx, "remote_file_url")

Get metadata of a transformed image

cURL
Node.js
Python
PHP
Java
Ruby
Go
.Net
# The URL of the uploaded file
curl -X GET "https://api.imagekit.io/v1/metadata?url=https://ik.imagekit.io/demo/tr:w-100/default-image.jpg" \
-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("https://ik.imagekit.io/demo/tr:w-100/default-image.jpg", function(error, result) {
if(error) console.log(error);
else console.log(result);
});
get_metadata = imagekit.get_remote_file_url_metadata(remote_file_url="https://ik.imagekit.io/demo/tr:w-100/default-image.jpg")
​
print(get_metadata, end="\n\n")
​
# Raw Response
print(get_metadata.response_metadata.raw)
​
# print the file metadata fields
print(get_metadata.width)
print(get_metadata.exif.image.x_resolution)
$imageKit->getFileMetadataFromRemoteURL("https://ik.imagekit.io/demo/tr:w-100/default-image.jpg")
ResultMetaData result=ImageKit.getInstance().getRemoteFileMetadata("https://ik.imagekit.io/demo/tr:w-100/default-image.jpg");
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
imagekitio.get_remote_file_url_metadata(remote_file_url: "https://ik.imagekit.io/demo/tr:w-100/default-image.jpg")
resp, err := ik.Metadata.FromUrl(ctx, "https://ik.imagekit.io/demo/tr:w-100/default-image.jpg")
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
ResultMetaData resultMetaData1 = imagekit.GetRemoteFileMetadata("https://ik.imagekit.io/demo/tr:w-100/default-image.jpg");

Calculate pHash distance between two images

See examples here.