Some images may contain Exchangeable Image File Format (EXIF) data that includes the attribute information and photographic information about the images. 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.

Parameter description

Operation name: info

The image information is returned in the JSON format.

Limits

Only JPG, PNG, BMP, GIF, WebP, TIFF, and HEIC images are supported.

Examples

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 an image that does not contain EXIF data

    https://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/info

    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"},
      "ImageHeight": {"value": "267"},
      "ImageWidth": {"value": "400"}
    }
  • Query an image that contains EXIF data

    https://image-demo.oss-cn-hangzhou.aliyuncs.com/f.jpg?x-oss-process=image/info

    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"}}

FAQ

How do I obtain the image information of a private image?

To obtain the image information, add the operation that can be used to obtain the image information to a signed URL by using OSS SDKs, and then use the URL to access the image.

  1. Generate a signed URL.

    The following 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.model.GeneratePresignedUrlRequest;
    import java.net.URL;
    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 = "https://oss-cn-hangzhou.aliyuncs.com";
            // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
            String accessKeyId = "yourAccessKeyId";
            String accessKeySecret = "yourAccessKeySecret";
            // 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, accessKeyId, accessKeySecret);
    
            try {
                // Obtain the image information. 
                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);
                req.setExpiration(expiration);
                req.setProcess(style);
                URL signedUrl = ossClient.generatePresignedUrl(req);
                System.out.println(signedUrl);
            } 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) {
                    ossClient.shutdown();
                }
            }
        }
    }
  2. Use the signed URL to access the image by using a browser and obtain the image information.