2
0

image.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. 'use strict';
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.PDFImage = undefined;
  27. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  28. var _util = require('../shared/util');
  29. var _primitives = require('./primitives');
  30. var _colorspace = require('./colorspace');
  31. var _stream = require('./stream');
  32. var _jpeg_stream = require('./jpeg_stream');
  33. var _jpx = require('./jpx');
  34. var PDFImage = function PDFImageClosure() {
  35. function handleImageData(image, nativeDecoder) {
  36. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  37. return nativeDecoder.decode(image);
  38. }
  39. return Promise.resolve(image);
  40. }
  41. function decodeAndClamp(value, addend, coefficient, max) {
  42. value = addend + value * coefficient;
  43. return value < 0 ? 0 : value > max ? max : value;
  44. }
  45. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46. var length = w2 * h2;
  47. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48. var xRatio = w1 / w2;
  49. var yRatio = h1 / h2;
  50. var i,
  51. j,
  52. py,
  53. newIndex = 0,
  54. oldIndex;
  55. var xScaled = new Uint16Array(w2);
  56. var w1Scanline = w1;
  57. for (i = 0; i < w2; i++) {
  58. xScaled[i] = Math.floor(i * xRatio);
  59. }
  60. for (i = 0; i < h2; i++) {
  61. py = Math.floor(i * yRatio) * w1Scanline;
  62. for (j = 0; j < w2; j++) {
  63. oldIndex = py + xScaled[j];
  64. dest[newIndex++] = src[oldIndex];
  65. }
  66. }
  67. return dest;
  68. }
  69. function PDFImage(_ref) {
  70. var xref = _ref.xref,
  71. res = _ref.res,
  72. image = _ref.image,
  73. _ref$isInline = _ref.isInline,
  74. isInline = _ref$isInline === undefined ? false : _ref$isInline,
  75. _ref$smask = _ref.smask,
  76. smask = _ref$smask === undefined ? null : _ref$smask,
  77. _ref$mask = _ref.mask,
  78. mask = _ref$mask === undefined ? null : _ref$mask,
  79. _ref$isMask = _ref.isMask,
  80. isMask = _ref$isMask === undefined ? false : _ref$isMask,
  81. pdfFunctionFactory = _ref.pdfFunctionFactory;
  82. this.image = image;
  83. var dict = image.dict;
  84. if (dict.has('Filter')) {
  85. var filter = dict.get('Filter').name;
  86. if (filter === 'JPXDecode') {
  87. var jpxImage = new _jpx.JpxImage();
  88. jpxImage.parseImageProperties(image.stream);
  89. image.stream.reset();
  90. image.bitsPerComponent = jpxImage.bitsPerComponent;
  91. image.numComps = jpxImage.componentsCount;
  92. } else if (filter === 'JBIG2Decode') {
  93. image.bitsPerComponent = 1;
  94. image.numComps = 1;
  95. }
  96. }
  97. this.width = dict.get('Width', 'W');
  98. this.height = dict.get('Height', 'H');
  99. if (this.width < 1 || this.height < 1) {
  100. throw new _util.FormatError('Invalid image width: ' + this.width + ' or ' + ('height: ' + this.height));
  101. }
  102. this.interpolate = dict.get('Interpolate', 'I') || false;
  103. this.imageMask = dict.get('ImageMask', 'IM') || false;
  104. this.matte = dict.get('Matte') || false;
  105. var bitsPerComponent = image.bitsPerComponent;
  106. if (!bitsPerComponent) {
  107. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  108. if (!bitsPerComponent) {
  109. if (this.imageMask) {
  110. bitsPerComponent = 1;
  111. } else {
  112. throw new _util.FormatError('Bits per component missing in image: ' + this.imageMask);
  113. }
  114. }
  115. }
  116. this.bpc = bitsPerComponent;
  117. if (!this.imageMask) {
  118. var colorSpace = dict.get('ColorSpace', 'CS');
  119. if (!colorSpace) {
  120. (0, _util.info)('JPX images (which do not require color spaces)');
  121. switch (image.numComps) {
  122. case 1:
  123. colorSpace = _primitives.Name.get('DeviceGray');
  124. break;
  125. case 3:
  126. colorSpace = _primitives.Name.get('DeviceRGB');
  127. break;
  128. case 4:
  129. colorSpace = _primitives.Name.get('DeviceCMYK');
  130. break;
  131. default:
  132. throw new Error('JPX images with ' + this.numComps + ' ' + 'color components not supported.');
  133. }
  134. }
  135. var resources = isInline ? res : null;
  136. this.colorSpace = _colorspace.ColorSpace.parse(colorSpace, xref, resources, pdfFunctionFactory);
  137. this.numComps = this.colorSpace.numComps;
  138. }
  139. this.decode = dict.getArray('Decode', 'D');
  140. this.needsDecode = false;
  141. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !_colorspace.ColorSpace.isDefaultDecode(this.decode, 1))) {
  142. this.needsDecode = true;
  143. var max = (1 << bitsPerComponent) - 1;
  144. this.decodeCoefficients = [];
  145. this.decodeAddends = [];
  146. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  147. var dmin = this.decode[i];
  148. var dmax = this.decode[i + 1];
  149. this.decodeCoefficients[j] = dmax - dmin;
  150. this.decodeAddends[j] = max * dmin;
  151. }
  152. }
  153. if (smask) {
  154. this.smask = new PDFImage({
  155. xref: xref,
  156. res: res,
  157. image: smask,
  158. isInline: isInline,
  159. pdfFunctionFactory: pdfFunctionFactory
  160. });
  161. } else if (mask) {
  162. if ((0, _primitives.isStream)(mask)) {
  163. var maskDict = mask.dict,
  164. imageMask = maskDict.get('ImageMask', 'IM');
  165. if (!imageMask) {
  166. (0, _util.warn)('Ignoring /Mask in image without /ImageMask.');
  167. } else {
  168. this.mask = new PDFImage({
  169. xref: xref,
  170. res: res,
  171. image: mask,
  172. isInline: isInline,
  173. isMask: true,
  174. pdfFunctionFactory: pdfFunctionFactory
  175. });
  176. }
  177. } else {
  178. this.mask = mask;
  179. }
  180. }
  181. }
  182. PDFImage.buildImage = function (_ref2) {
  183. var handler = _ref2.handler,
  184. xref = _ref2.xref,
  185. res = _ref2.res,
  186. image = _ref2.image,
  187. _ref2$isInline = _ref2.isInline,
  188. isInline = _ref2$isInline === undefined ? false : _ref2$isInline,
  189. _ref2$nativeDecoder = _ref2.nativeDecoder,
  190. nativeDecoder = _ref2$nativeDecoder === undefined ? null : _ref2$nativeDecoder,
  191. pdfFunctionFactory = _ref2.pdfFunctionFactory;
  192. var imagePromise = handleImageData(image, nativeDecoder);
  193. var smaskPromise;
  194. var maskPromise;
  195. var smask = image.dict.get('SMask');
  196. var mask = image.dict.get('Mask');
  197. if (smask) {
  198. smaskPromise = handleImageData(smask, nativeDecoder);
  199. maskPromise = Promise.resolve(null);
  200. } else {
  201. smaskPromise = Promise.resolve(null);
  202. if (mask) {
  203. if ((0, _primitives.isStream)(mask)) {
  204. maskPromise = handleImageData(mask, nativeDecoder);
  205. } else if (Array.isArray(mask)) {
  206. maskPromise = Promise.resolve(mask);
  207. } else {
  208. (0, _util.warn)('Unsupported mask format.');
  209. maskPromise = Promise.resolve(null);
  210. }
  211. } else {
  212. maskPromise = Promise.resolve(null);
  213. }
  214. }
  215. return Promise.all([imagePromise, smaskPromise, maskPromise]).then(function (_ref3) {
  216. var _ref4 = _slicedToArray(_ref3, 3),
  217. imageData = _ref4[0],
  218. smaskData = _ref4[1],
  219. maskData = _ref4[2];
  220. return new PDFImage({
  221. xref: xref,
  222. res: res,
  223. image: imageData,
  224. isInline: isInline,
  225. smask: smaskData,
  226. mask: maskData,
  227. pdfFunctionFactory: pdfFunctionFactory
  228. });
  229. });
  230. };
  231. PDFImage.createMask = function (_ref5) {
  232. var imgArray = _ref5.imgArray,
  233. width = _ref5.width,
  234. height = _ref5.height,
  235. imageIsFromDecodeStream = _ref5.imageIsFromDecodeStream,
  236. inverseDecode = _ref5.inverseDecode;
  237. var computedLength = (width + 7 >> 3) * height;
  238. var actualLength = imgArray.byteLength;
  239. var haveFullData = computedLength === actualLength;
  240. var data, i;
  241. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  242. data = imgArray;
  243. } else if (!inverseDecode) {
  244. data = new Uint8Array(actualLength);
  245. data.set(imgArray);
  246. } else {
  247. data = new Uint8Array(computedLength);
  248. data.set(imgArray);
  249. for (i = actualLength; i < computedLength; i++) {
  250. data[i] = 0xff;
  251. }
  252. }
  253. if (inverseDecode) {
  254. for (i = 0; i < actualLength; i++) {
  255. data[i] ^= 0xFF;
  256. }
  257. }
  258. return {
  259. data: data,
  260. width: width,
  261. height: height
  262. };
  263. };
  264. PDFImage.prototype = {
  265. get drawWidth() {
  266. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  267. },
  268. get drawHeight() {
  269. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  270. },
  271. decodeBuffer: function decodeBuffer(buffer) {
  272. var bpc = this.bpc;
  273. var numComps = this.numComps;
  274. var decodeAddends = this.decodeAddends;
  275. var decodeCoefficients = this.decodeCoefficients;
  276. var max = (1 << bpc) - 1;
  277. var i, ii;
  278. if (bpc === 1) {
  279. for (i = 0, ii = buffer.length; i < ii; i++) {
  280. buffer[i] = +!buffer[i];
  281. }
  282. return;
  283. }
  284. var index = 0;
  285. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  286. for (var j = 0; j < numComps; j++) {
  287. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  288. index++;
  289. }
  290. }
  291. },
  292. getComponents: function getComponents(buffer) {
  293. var bpc = this.bpc;
  294. if (bpc === 8) {
  295. return buffer;
  296. }
  297. var width = this.width;
  298. var height = this.height;
  299. var numComps = this.numComps;
  300. var length = width * height * numComps;
  301. var bufferPos = 0;
  302. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  303. var rowComps = width * numComps;
  304. var max = (1 << bpc) - 1;
  305. var i = 0,
  306. ii,
  307. buf;
  308. if (bpc === 1) {
  309. var mask, loop1End, loop2End;
  310. for (var j = 0; j < height; j++) {
  311. loop1End = i + (rowComps & ~7);
  312. loop2End = i + rowComps;
  313. while (i < loop1End) {
  314. buf = buffer[bufferPos++];
  315. output[i] = buf >> 7 & 1;
  316. output[i + 1] = buf >> 6 & 1;
  317. output[i + 2] = buf >> 5 & 1;
  318. output[i + 3] = buf >> 4 & 1;
  319. output[i + 4] = buf >> 3 & 1;
  320. output[i + 5] = buf >> 2 & 1;
  321. output[i + 6] = buf >> 1 & 1;
  322. output[i + 7] = buf & 1;
  323. i += 8;
  324. }
  325. if (i < loop2End) {
  326. buf = buffer[bufferPos++];
  327. mask = 128;
  328. while (i < loop2End) {
  329. output[i++] = +!!(buf & mask);
  330. mask >>= 1;
  331. }
  332. }
  333. }
  334. } else {
  335. var bits = 0;
  336. buf = 0;
  337. for (i = 0, ii = length; i < ii; ++i) {
  338. if (i % rowComps === 0) {
  339. buf = 0;
  340. bits = 0;
  341. }
  342. while (bits < bpc) {
  343. buf = buf << 8 | buffer[bufferPos++];
  344. bits += 8;
  345. }
  346. var remainingBits = bits - bpc;
  347. var value = buf >> remainingBits;
  348. output[i] = value < 0 ? 0 : value > max ? max : value;
  349. buf = buf & (1 << remainingBits) - 1;
  350. bits = remainingBits;
  351. }
  352. }
  353. return output;
  354. },
  355. fillOpacity: function fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  356. var smask = this.smask;
  357. var mask = this.mask;
  358. var alphaBuf, sw, sh, i, ii, j;
  359. if (smask) {
  360. sw = smask.width;
  361. sh = smask.height;
  362. alphaBuf = new Uint8Array(sw * sh);
  363. smask.fillGrayBuffer(alphaBuf);
  364. if (sw !== width || sh !== height) {
  365. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  366. }
  367. } else if (mask) {
  368. if (mask instanceof PDFImage) {
  369. sw = mask.width;
  370. sh = mask.height;
  371. alphaBuf = new Uint8Array(sw * sh);
  372. mask.numComps = 1;
  373. mask.fillGrayBuffer(alphaBuf);
  374. for (i = 0, ii = sw * sh; i < ii; ++i) {
  375. alphaBuf[i] = 255 - alphaBuf[i];
  376. }
  377. if (sw !== width || sh !== height) {
  378. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  379. }
  380. } else if (Array.isArray(mask)) {
  381. alphaBuf = new Uint8Array(width * height);
  382. var numComps = this.numComps;
  383. for (i = 0, ii = width * height; i < ii; ++i) {
  384. var opacity = 0;
  385. var imageOffset = i * numComps;
  386. for (j = 0; j < numComps; ++j) {
  387. var color = image[imageOffset + j];
  388. var maskOffset = j * 2;
  389. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  390. opacity = 255;
  391. break;
  392. }
  393. }
  394. alphaBuf[i] = opacity;
  395. }
  396. } else {
  397. throw new _util.FormatError('Unknown mask format.');
  398. }
  399. }
  400. if (alphaBuf) {
  401. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  402. rgbaBuf[j] = alphaBuf[i];
  403. }
  404. } else {
  405. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  406. rgbaBuf[j] = 255;
  407. }
  408. }
  409. },
  410. undoPreblend: function undoPreblend(buffer, width, height) {
  411. var matte = this.smask && this.smask.matte;
  412. if (!matte) {
  413. return;
  414. }
  415. var matteRgb = this.colorSpace.getRgb(matte, 0);
  416. var matteR = matteRgb[0];
  417. var matteG = matteRgb[1];
  418. var matteB = matteRgb[2];
  419. var length = width * height * 4;
  420. var r, g, b;
  421. for (var i = 0; i < length; i += 4) {
  422. var alpha = buffer[i + 3];
  423. if (alpha === 0) {
  424. buffer[i] = 255;
  425. buffer[i + 1] = 255;
  426. buffer[i + 2] = 255;
  427. continue;
  428. }
  429. var k = 255 / alpha;
  430. r = (buffer[i] - matteR) * k + matteR;
  431. g = (buffer[i + 1] - matteG) * k + matteG;
  432. b = (buffer[i + 2] - matteB) * k + matteB;
  433. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  434. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  435. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  436. }
  437. },
  438. createImageData: function createImageData() {
  439. var forceRGBA = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  440. var drawWidth = this.drawWidth;
  441. var drawHeight = this.drawHeight;
  442. var imgData = {
  443. width: drawWidth,
  444. height: drawHeight
  445. };
  446. var numComps = this.numComps;
  447. var originalWidth = this.width;
  448. var originalHeight = this.height;
  449. var bpc = this.bpc;
  450. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  451. var imgArray;
  452. if (!forceRGBA) {
  453. var kind;
  454. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  455. kind = _util.ImageKind.GRAYSCALE_1BPP;
  456. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  457. kind = _util.ImageKind.RGB_24BPP;
  458. }
  459. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  460. imgData.kind = kind;
  461. imgArray = this.getImageBytes(originalHeight * rowBytes);
  462. if (this.image instanceof _stream.DecodeStream) {
  463. imgData.data = imgArray;
  464. } else {
  465. var newArray = new Uint8Array(imgArray.length);
  466. newArray.set(imgArray);
  467. imgData.data = newArray;
  468. }
  469. if (this.needsDecode) {
  470. (0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP);
  471. var buffer = imgData.data;
  472. for (var i = 0, ii = buffer.length; i < ii; i++) {
  473. buffer[i] ^= 0xff;
  474. }
  475. }
  476. return imgData;
  477. }
  478. if (this.image instanceof _jpeg_stream.JpegStream && !this.smask && !this.mask) {
  479. var imageLength = originalHeight * rowBytes;
  480. switch (this.colorSpace.name) {
  481. case 'DeviceGray':
  482. imageLength *= 3;
  483. case 'DeviceRGB':
  484. case 'DeviceCMYK':
  485. imgData.kind = _util.ImageKind.RGB_24BPP;
  486. imgData.data = this.getImageBytes(imageLength, drawWidth, drawHeight, true);
  487. return imgData;
  488. }
  489. }
  490. }
  491. imgArray = this.getImageBytes(originalHeight * rowBytes);
  492. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  493. var comps = this.getComponents(imgArray);
  494. var alpha01, maybeUndoPreblend;
  495. if (!forceRGBA && !this.smask && !this.mask) {
  496. imgData.kind = _util.ImageKind.RGB_24BPP;
  497. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  498. alpha01 = 0;
  499. maybeUndoPreblend = false;
  500. } else {
  501. imgData.kind = _util.ImageKind.RGBA_32BPP;
  502. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  503. alpha01 = 1;
  504. maybeUndoPreblend = true;
  505. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  506. }
  507. if (this.needsDecode) {
  508. this.decodeBuffer(comps);
  509. }
  510. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  511. if (maybeUndoPreblend) {
  512. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  513. }
  514. return imgData;
  515. },
  516. fillGrayBuffer: function fillGrayBuffer(buffer) {
  517. var numComps = this.numComps;
  518. if (numComps !== 1) {
  519. throw new _util.FormatError('Reading gray scale from a color image: ' + numComps);
  520. }
  521. var width = this.width;
  522. var height = this.height;
  523. var bpc = this.bpc;
  524. var rowBytes = width * numComps * bpc + 7 >> 3;
  525. var imgArray = this.getImageBytes(height * rowBytes);
  526. var comps = this.getComponents(imgArray);
  527. var i, length;
  528. if (bpc === 1) {
  529. length = width * height;
  530. if (this.needsDecode) {
  531. for (i = 0; i < length; ++i) {
  532. buffer[i] = comps[i] - 1 & 255;
  533. }
  534. } else {
  535. for (i = 0; i < length; ++i) {
  536. buffer[i] = -comps[i] & 255;
  537. }
  538. }
  539. return;
  540. }
  541. if (this.needsDecode) {
  542. this.decodeBuffer(comps);
  543. }
  544. length = width * height;
  545. var scale = 255 / ((1 << bpc) - 1);
  546. for (i = 0; i < length; ++i) {
  547. buffer[i] = scale * comps[i] | 0;
  548. }
  549. },
  550. getImageBytes: function getImageBytes(length, drawWidth, drawHeight) {
  551. var forceRGB = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  552. this.image.reset();
  553. this.image.drawWidth = drawWidth || this.width;
  554. this.image.drawHeight = drawHeight || this.height;
  555. this.image.forceRGB = !!forceRGB;
  556. return this.image.getBytes(length);
  557. }
  558. };
  559. return PDFImage;
  560. }();
  561. exports.PDFImage = PDFImage;