image_data.js 826 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. class ImageData {
  7. static from(input) {
  8. return new ImageData(input.data || input._data, input.width, input.height);
  9. }
  10. get data() {
  11. if (Object.prototype.toString.call(this._data) === "[object Object]") {
  12. return Buffer.from(Object.values(this._data));
  13. }
  14. if (this._data instanceof Buffer || this._data instanceof Uint8Array || this._data instanceof Uint8ClampedArray) {
  15. return Buffer.from(this._data);
  16. }
  17. throw new Error("invariant");
  18. }
  19. constructor(data, width, height){
  20. this._data = data;
  21. this.width = width;
  22. this.height = height;
  23. }
  24. }
  25. exports.default = ImageData;
  26. //# sourceMappingURL=image_data.js.map