@shibam/sticker-maker 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -130,6 +130,7 @@ var Sticker = /** @class */ (function () {
130
130
  case 3:
131
131
  _a.outBuffer = _b.sent();
132
132
  this.activeBuff = true;
133
+ this.outBuffer = this.extType !== 'gif' ? this.outBuffer : buffer;
133
134
  return [2 /*return*/, this.outBuffer];
134
135
  case 4:
135
136
  error_2 = _b.sent();
@@ -109,7 +109,7 @@ var ToWebp = function (buffer, metaInfo, mimeExt, mimeType) { return __awaiter(v
109
109
  '-r 15',
110
110
  '-loop 0',
111
111
  '-metadata:s:v:0 alpha_mode="1"',
112
- mimeExt === 'gif' ? '-lossless 1' : '-lossless 0'
112
+ '-lossless 1'
113
113
  ].join(' ')
114
114
  : '-c:v libwebp',
115
115
  '-q:v',
@@ -51,7 +51,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var node_webpmux_1 = __importDefault(require("node-webpmux"));
54
- var util_1 = require("util");
55
54
  /**
56
55
  * The Exif class is responsible for handling the metadata (Exif data)
57
56
  * for sticker images, particularly those used in messaging applications.
@@ -71,16 +70,21 @@ var Exif = /** @class */ (function () {
71
70
  */
72
71
  this.build = function () {
73
72
  var data = JSON.stringify(_this.data);
74
- // Construct the Exif header and data sections.
75
- var exif = Buffer.concat([
76
- Buffer.from([
77
- 0x49, 0x49, 0x2a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00,
78
- 0x00, 0x16, 0x00, 0x00, 0x00
79
- ]),
80
- Buffer.from(data, 'utf-8')
81
- ]);
73
+ var dataBuffer = Buffer.from(data, 'utf-8');
74
+ // Construct the Exif header.
75
+ var exifHeader = Buffer.alloc(22); // Allocate a new buffer of the correct size
76
+ exifHeader.write('Exif\0\0', 0); // Exif header
77
+ exifHeader.writeUInt16LE(0x4949, 6); // II for little-endian
78
+ exifHeader.writeUInt16LE(0x002a, 8); // TIFF header
79
+ exifHeader.writeUInt32LE(0x00000008, 10); // Offset to first IFD
80
+ // Write the APP1 marker and size
81
+ var app1Marker = Buffer.from([0xff, 0xe1]);
82
+ var app1Size = Buffer.alloc(2);
83
+ app1Size.writeUInt16BE(2 + exifHeader.length + dataBuffer.length);
82
84
  // Write the length of the data into the Exif header.
83
- exif.writeUIntLE(new util_1.TextEncoder().encode(data).length, 14, 4);
85
+ exifHeader.writeUInt32LE(dataBuffer.length, 14);
86
+ // Concatenate all parts
87
+ var exif = Buffer.concat([app1Marker, app1Size, exifHeader, dataBuffer]);
84
88
  return exif;
85
89
  };
86
90
  /**
@@ -90,6 +94,7 @@ var Exif = /** @class */ (function () {
90
94
  */
91
95
  this.add = function (image) { return __awaiter(_this, void 0, void 0, function () {
92
96
  var exif, _a;
97
+ var _this = this;
93
98
  return __generator(this, function (_b) {
94
99
  switch (_b.label) {
95
100
  case 0:
@@ -97,7 +102,19 @@ var Exif = /** @class */ (function () {
97
102
  if (!(image instanceof node_webpmux_1.default.Image)) return [3 /*break*/, 1];
98
103
  _a = image;
99
104
  return [3 /*break*/, 3];
100
- case 1: return [4 /*yield*/, this.load(image)
105
+ case 1: return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
106
+ var img;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ img = new node_webpmux_1.default.Image();
111
+ return [4 /*yield*/, img.load(image)];
112
+ case 1:
113
+ _a.sent();
114
+ return [2 /*return*/, img];
115
+ }
116
+ });
117
+ }); })()
101
118
  // Set the Exif data on the image and save it.
102
119
  ];
103
120
  case 2:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shibam/sticker-maker",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A package for creating stickers",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
@@ -34,12 +34,11 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "file-type": "16.5.0",
37
- "node-webpmux": "^3.2.0",
38
- "prettier": "^3.3.2"
37
+ "node-webpmux": "^3.2.0"
39
38
  },
40
39
  "devDependencies": {
41
40
  "@types/node": "^20.10.0",
42
41
  "tsx": "^4.7.1",
43
42
  "typescript": "^5.4.5"
44
43
  }
45
- }
44
+ }