Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to keep metadata #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = options => async buffer => {
paletteReduction: true,
interlaced: false,
errorRecovery: true,
strip: true,
...options
};

Expand All @@ -23,15 +24,18 @@ module.exports = options => async buffer => {
}

const arguments_ = [
'-strip',
'all',
'-clobber',
'-o',
options.optimizationLevel,
'-out',
execBuffer.output
];

if (options.strip) {
arguments_.unshift('all');
arguments_.unshift('-strip');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use .push. And one call is enough.

}

if (options.errorRecovery) {
arguments_.push('-fix');
}
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ Default: `true`

A reasonable amount of effort will be spent to try to recover as much data as possible of a broken image, but the success cannot generally be guaranteed.

##### strip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
##### strip
##### stripMetadata

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but wouldn't that strip metadata? Or would that be too simple

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you're asking. I'm saying the option should be named better as it only strips metadata.


Type: `boolean`<br>
Default: `false`

Strip metadata objects from a PNG file.

#### buffer

Type: `Buffer`
Expand Down