You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
118
-
This will also convert to and add a web-friendly sRGB ICC profile if appropriate,
119
-
unless a custom output profile is provided.
120
-
121
-
The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
122
-
sRGB colour space and strip all metadata, including the removal of any ICC profile.
117
+
Keep all EXIF metadata from the input image in the output image.
123
118
124
119
EXIF metadata is unsupported for TIFF output.
125
120
126
121
122
+
**Since**: 0.33.0
123
+
**Example**
124
+
```js
125
+
constoutputWithExif=awaitsharp(inputWithExif)
126
+
.keepExif()
127
+
.toBuffer();
128
+
```
129
+
130
+
131
+
## withExif
132
+
> withExif(exif) ⇒ <code>Sharp</code>
133
+
134
+
Set EXIF metadata in the output image, ignoring any EXIF in the input image.
135
+
136
+
137
+
**Throws**:
138
+
139
+
- <code>Error</code> Invalid parameters
140
+
141
+
**Since**: 0.33.0
142
+
143
+
| Param | Type | Description |
144
+
| --- | --- | --- |
145
+
| exif | <code>Object.<string, Object.<string, string>></code> | Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data. |
146
+
147
+
**Example**
148
+
```js
149
+
constdataWithExif=awaitsharp(input)
150
+
.withExif({
151
+
IFD0: {
152
+
Copyright:'The National Gallery'
153
+
},
154
+
IFD3: {
155
+
GPSLatitudeRef:'N',
156
+
GPSLatitude:'51/1 30/1 3230/100',
157
+
GPSLongitudeRef:'W',
158
+
GPSLongitude:'0/1 7/1 4366/100'
159
+
}
160
+
})
161
+
.toBuffer();
162
+
```
163
+
164
+
165
+
## withExifMerge
166
+
> withExifMerge(exif) ⇒ <code>Sharp</code>
167
+
168
+
Update EXIF metadata from the input image in the output image.
169
+
170
+
171
+
**Throws**:
172
+
173
+
- <code>Error</code> Invalid parameters
174
+
175
+
**Since**: 0.33.0
176
+
177
+
| Param | Type | Description |
178
+
| --- | --- | --- |
179
+
| exif | <code>Object.<string, Object.<string, string>></code> | Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data. |
180
+
181
+
**Example**
182
+
```js
183
+
constdataWithMergedExif=awaitsharp(inputWithExif)
184
+
.withExifMerge({
185
+
IFD0: {
186
+
Copyright:'The National Gallery'
187
+
}
188
+
})
189
+
.toBuffer();
190
+
```
191
+
192
+
193
+
## keepIccProfile
194
+
> keepIccProfile() ⇒ <code>Sharp</code>
195
+
196
+
Keep ICC profile from the input image in the output image.
197
+
198
+
Where necessary, will attempt to convert the output colour space to match the profile.
Transform using an ICC profile and attach to the output image.
214
+
215
+
This can either be an absolute filesystem path or
216
+
built-in profile name (`srgb`, `p3`, `cmyk`).
217
+
218
+
127
219
**Throws**:
128
220
129
221
- <code>Error</code> Invalid parameters
130
222
223
+
**Since**: 0.33.0
131
224
132
225
| Param | Type | Default | Description |
133
226
| --- | --- | --- | --- |
227
+
| icc | <code>string</code> || Absolute filesystem path to output ICC profile or built-in profile name (srgb, p3, cmyk). |
134
228
|[options]| <code>Object</code> |||
135
-
|[options.orientation]| <code>number</code> || value between 1 and 8, used to update the EXIF `Orientation` tag. |
136
-
|[options.icc]| <code>string</code> | <code>"'srgb'"</code> | Filesystem path to output ICC profile, relative to `process.cwd()`, defaults to built-in sRGB. |
137
-
|[options.exif]| <code>Object.<Object></code> | <code>{}</code> | Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data. |
138
-
|[options.density]| <code>number</code> || Number of pixels per inch (DPI). |
229
+
|[options.attach]| <code>number</code> | <code>true</code> | Should the ICC profile be included in the output image metadata? |
139
230
140
231
**Example**
141
232
```js
142
-
sharp('input.jpg')
143
-
.withMetadata()
144
-
.toFile('output-with-metadata.jpg')
145
-
.then(info=> { ... });
233
+
constoutputWithP3=awaitsharp(input)
234
+
.withIccProfile('p3')
235
+
.toBuffer();
146
236
```
237
+
238
+
239
+
## keepMetadata
240
+
> keepMetadata() ⇒ <code>Sharp</code>
241
+
242
+
Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.
243
+
244
+
The default behaviour, when `keepMetadata` is not used, is to convert to the device-independent
245
+
sRGB colour space and strip all metadata, including the removal of any ICC profile.
0 commit comments