1# Editing EXIF Data 2<!--Kit: Image Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @aulight02--> 5<!--SE: @liyang_bryan--> 6<!--TSE: @xchaosioda--> 7 8Image Kit provides the capabilities of reading and editing Exchangeable Image File Format (EXIF) data. 9 10EXIF is a file format dedicated for photos taken by digital cameras and is used to record attributes and shooting data of the photos. Currently, JPEG, PNG, and HEIF images that contain EXIF data are supported. 11 12Users may need to view or modify the EXIF data of photos in the Gallery application, for example, when the manual lens parameters of the camera are not automatically written as part of the EXIF data or the shooting time is incorrect due to camera power-off. 13 14Currently, OpenHarmony allows you to view and modify part of EXIF data. For details, see [Exif](../../reference/apis-image-kit/arkts-apis-image-e.md#propertykey7). 15 16## How to Develop 17 18Read the [API reference](../../reference/apis-image-kit/arkts-apis-image-ImageSource.md#getimageproperty11) for APIs used to read and edit EXIF data. 19 20Obtain the image and create an ImageSource object. Read and edit EXIF data. The code snippet is as follows: 21 22```ts 23// Import the required module. 24import { image } from '@kit.ImageKit'; 25import { BusinessError } from '@kit.BasicServicesKit'; 26 27// Obtain the sandbox path and create an ImageSource object. 28const fd : number = 0; // Obtain the file descriptor of the image to be processed. 29const imageSourceApi : image.ImageSource = image.createImageSource(fd); 30 31// Read the EXIF data, where BitsPerSample indicates the number of bits per pixel. 32let options : image.ImagePropertyOptions = { index: 0, defaultValue: 'This key has no value!' }; 33imageSourceApi.getImageProperty(image.PropertyKey.BITS_PER_SAMPLE, options).then((data : string) => { 34 console.info('Succeeded in getting the value of the specified attribute key of the image.'); 35}).catch((error : BusinessError) => { 36 console.error('Failed to get the value of the specified attribute key of the image.'); 37}) 38 39// Edit the EXIF data. 40imageSourceApi.modifyImageProperty(image.PropertyKey.IMAGE_WIDTH, "120").then(() => { 41 imageSourceApi.getImageProperty(image.PropertyKey.IMAGE_WIDTH).then((width : string) => { 42 console.info('The new imageWidth is ' + width); 43 }).catch((error : BusinessError) => { 44 console.error('Failed to get the Image Width.'); 45 }) 46}).catch((error : BusinessError) => { 47 console.error('Failed to modify the Image Width'); 48}) 49``` 50