All Products
Document Center

Object Storage Service:Query image information

Last Updated:Mar 26, 2024

Some images may contain Exchangeable Image File Format (EXIF) data that includes image attributes and shooting settings. The EXIF data of an image includes image information such as the compression ratio, orientation, horizontal resolution, and vertical resolution. If you want to obtain the EXIF data of an image, add the info parameter to the URL of the image.


Action: info

The returned information is in the JSON format.


You can use the info action to query information about only JPG, PNG, BMP, GIF, WebP, TIFF, and HEIC images.


You cannot use the info action to query EXIF data of PNG images.


You can use object URLs, OSS SDKs, or API operations to configure IMG parameters that are used to process images. In this example, object URLs are used. You can use object URLs to configure IMG parameters only for public-read images. If you want to configure IMG parameters for private images, use OSS SDKs or API operations. For more information, see IMG implementation modes.

  • Query information about an image that does not contain EXIF data

    If you add the info parameter to the URL of an image that does not contain EXIF data, only the basic information about the image is returned, such as the size, format, height, and width of the image.

      "FileSize": {"value": "21839"},
      "Format": {"value": "jpg"},
      "FrameCount": {"value": "1"},
      "ImageHeight": {"value": "267"},
      "ImageWidth": {"value": "400"},
      "ResolutionUnit": {"value": "1"},
      "XResolution": {"value": "1/1"},
      "YResolution": {"value": "1/1"}
  • Query information about an image that contains EXIF data

    If you add the info parameter to the URL of an image that contains EXIF data, the basic information about the image and the EXIF data of the image is returned. For more information about EXIF data, see Exif Version 2.31.

      "Compression": {"value": "6"},
      "DateTime": {"value": "2015:02:11 15:38:27"},
      "ExifTag": {"value": "2212"},
      "FileSize": {"value": "23471"},
      "Format": {"value": "jpg"},
      "GPSLatitude": {"value": "0deg "},
      "GPSLatitudeRef": {"value": "North"},
      "GPSLongitude": {"value": "0deg "},
      "GPSLongitudeRef": {"value": "East"},
      "GPSMapDatum": {"value": "WGS-84"},
      "GPSTag": {"value": "4292"},
      "GPSVersionID": {"value": "2 2 0 0"},
      "ImageHeight": {"value": "333"},
      "ImageWidth": {"value": "424"},
      "JPEGInterchangeFormat": {"value": "4518"},
      "JPEGInterchangeFormatLength": {"value": "3232"},
      "Orientation": {"value": "7"},
      "ResolutionUnit": {"value": "2"},
      "Software": {"value": "Microsoft Windows Photo Viewer 6.1.7600.16385"},
      "XResolution": {"value": "96/1"},
      "YResolution": {"value": "96/1"}}


How do I query information about a private image?

To query information about a private image, add the info parameter to a signed URL by using OSS SDKs and then use the URL to access the image.

  1. Generate a signed URL.

    The following sample code provides an example on how to use OSS SDK for Java to generate a signed URL:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.model.GeneratePresignedUrlRequest;
    import java.util.Date;
    public class Demo {
        public static void main(String[] args) throws Throwable {
            // In this example, the endpoint of the China (Hangzhou) region is used. Specify your actual endpoint. 
            String endpoint = "";
            // For security purposes, we recommend that you do not save access credentials in the project code. In this example, access credentials are obtained from environment variables. Before you run the sample code, make sure that the environment variables are configured. 
            EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
            // Specify the name of the bucket. Example: examplebucket. 
            String bucketName = "examplebucket";
            // Specify the full path of the object. Do not include the bucket name in the full path. 
            String objectName = "exampleobject.jpg";
            // Create an OSSClient instance. 
            OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
            try {
                // Query information about the image object. 
                String style = "image/info";
                // Set the validity period of the signed URL to 10 minutes. 
                Date expiration = new Date(new Date().getTime() + 1000 * 60 * 10 );
                GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, objectName, HttpMethod.GET);
                URL signedUrl = ossClient.generatePresignedUrl(req);
            } catch (OSSException oe) {
                System.out.println("Caught an OSSException, which means your request made it to OSS, "
                        + "but was rejected with an error response for some reason.");
                System.out.println("Error Message:" + oe.getErrorMessage());
                System.out.println("Error Code:" + oe.getErrorCode());
                System.out.println("Request ID:" + oe.getRequestId());
                System.out.println("Host ID:" + oe.getHostId());
            } catch (ClientException ce) {
                System.out.println("Caught an ClientException, which means the client encountered "
                        + "a serious internal problem while trying to communicate with OSS, "
                        + "such as not being able to access the network.");
                System.out.println("Error Message:" + ce.getMessage());
            } finally {
                if (ossClient != null) {
  2. Use the signed URL to access the image from a browser to query image information.