MCPcopy Index your code
hub / github.com/lovell/sharp / metadata

Function metadata

lib/input.mjs:641–696  ·  view source on GitHub ↗

* Fast access to (uncached) image metadata without decoding any compressed pixel data. * * This is read from the header of the input image. * It does not take into consideration any operations to be applied to the output image, * such as resize or rotate. * * Dimensions in the response will re

(callback)

Source from the content-addressed store, hash-verified

639 * @returns {Promise<Object>|Sharp}
640 */
641function metadata (callback) {
642 const stack = Error();
643 if (is.fn(callback)) {
644 if (this._isStreamInput()) {
645 this.on('finish', () => {
646 this._flattenBufferIn();
647 sharp.metadata(this.options, (err, metadata) => {
648 if (err) {
649 callback(is.nativeError(err, stack));
650 } else {
651 callback(null, metadata);
652 }
653 });
654 });
655 } else {
656 sharp.metadata(this.options, (err, metadata) => {
657 if (err) {
658 callback(is.nativeError(err, stack));
659 } else {
660 callback(null, metadata);
661 }
662 });
663 }
664 return this;
665 } else {
666 if (this._isStreamInput()) {
667 return new Promise((resolve, reject) => {
668 const finished = () => {
669 this._flattenBufferIn();
670 sharp.metadata(this.options, (err, metadata) => {
671 if (err) {
672 reject(is.nativeError(err, stack));
673 } else {
674 resolve(metadata);
675 }
676 });
677 };
678 if (this.writableFinished) {
679 finished();
680 } else {
681 this.once('finish', finished);
682 }
683 });
684 } else {
685 return new Promise((resolve, reject) => {
686 sharp.metadata(this.options, (err, metadata) => {
687 if (err) {
688 reject(is.nativeError(err, stack));
689 } else {
690 resolve(metadata);
691 }
692 });
693 });
694 }
695 }
696}
697
698/**

Callers

nothing calls this directly

Calls 2

finishedFunction · 0.85
metadataMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…