Skip to content

Commit

Permalink
feat: options to preserve image EXIF data and video metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Holayn authored and rprieto committed Sep 10, 2022
1 parent bbbee24 commit 5d0c34e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ opts = { height: 100, width: 100 }
opts = { quality: 80 }
```

##### Preserve EXIF Data

```js
// note: this will no longer auto-orient images according to its EXIF data
opts = { preserveExif: true }
```

##### Watermark

You can overlay a transparent watermark over the final image:
Expand Down Expand Up @@ -220,6 +227,12 @@ opts = { framerate: 60 }
opts = { framerate: 0 } // preserve the original source video's FPS
```

##### Preserve Metadata

```js
opts = { preserveMetadata: true }
```

##### Conversion progress

The `.video()` call returns an [EventEmitter](https://nodejs.org/api/events.html)
Expand Down
7 changes: 5 additions & 2 deletions lib/image/gmagick.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ exports.prepare = function (source, options) {
// start processing with GraphicsMagick
const image = gm(source)

// read baked-in orientation info, and output a rotated image with orientation=0
image.autoOrient()
if (!options.preserveExif) {
// read baked-in orientation info, and output a rotated image with orientation=0
// note: this strips EXIF data
image.autoOrient()
}

// optional watermark
const cropping = options.width && options.height
Expand Down
4 changes: 4 additions & 0 deletions lib/video/ffargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ exports.prepare = function (source, target, options) {
// misc options
args.push('-vsync', '2', '-movflags', '+faststart')

if (options.preserveMetadata) {
args.push('-map_metadata', 0)
}

// audio bitrate
args.push('-ab', DEFAULT_AUDIO_BITRATE)

Expand Down

0 comments on commit 5d0c34e

Please sign in to comment.