sharp-cli icon indicating copy to clipboard operation
sharp-cli copied to clipboard

Allow metadata retrieval

Open vseventer opened this issue 2 years ago • 0 comments

This Pull Request:

  • [x] Adds a --dry flag that, when set, allows you to do dry runs (i.e. do everything except write files).
  • [ ] Adds a --printMetadata flag that, when set, prints a metadata structure (JSON) containing metadata of the input and output.

Example

An example of the resulting metadata (WIP):

{
  input: {
    format: 'jpeg',
    size: 30985,
    width: 500,
    height: 331,
    space: 'srgb',
    channels: 3,
    depth: 'uchar',
    density: 72,
    chromaSubsampling: '4:2:0',
    isProgressive: false,
    hasProfile: false,
    hasAlpha: false,
    path: 'input.jpg'
  },
  output: {
    format: 'jpeg',
    width: 200,
    height: 132,
    channels: 3,
    premultiplied: false,
    size: 7742,
    path: 'output.jpg'
  }
}

Things to Note:

  • The dry run flag is required if you just want to get input metadata and not actually transform the input - this would be something like sharp -i ./input.jpg -o ./ --dry --printMetadata.
  • Solves #48.

vseventer avatar Jun 22 '22 00:06 vseventer