bare-exif 1.0.1 → 1.1.0
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/README.md +8 -1
- package/binding.c +66 -0
- package/index.js +8 -0
- package/package.json +5 -5
- package/prebuilds/android-arm/bare-exif.bare +0 -0
- package/prebuilds/android-arm64/bare-exif.bare +0 -0
- package/prebuilds/android-ia32/bare-exif.bare +0 -0
- package/prebuilds/android-x64/bare-exif.bare +0 -0
- package/prebuilds/darwin-arm64/bare-exif.bare +0 -0
- package/prebuilds/darwin-x64/bare-exif.bare +0 -0
- package/prebuilds/ios-arm64/bare-exif.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-exif.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-exif.bare +0 -0
- package/prebuilds/linux-arm64/bare-exif.bare +0 -0
- package/prebuilds/linux-x64/bare-exif.bare +0 -0
- package/prebuilds/win32-arm64/bare-exif.bare +0 -0
- package/prebuilds/win32-x64/bare-exif.bare +0 -0
package/README.md
CHANGED
|
@@ -13,12 +13,19 @@ const exif = require('bare-exif')
|
|
|
13
13
|
|
|
14
14
|
const image = require('./my-image.jpg', { with: { type: 'binary' } })
|
|
15
15
|
|
|
16
|
+
// Read EXIF data
|
|
16
17
|
const data = new exif.Data(image)
|
|
17
|
-
|
|
18
18
|
const orientation = data.entry(exif.constants.tags.ORIENTATION)
|
|
19
19
|
|
|
20
20
|
orientation.read() // 1 (raw value)
|
|
21
21
|
orientation.value() // Top-left (human readable string)
|
|
22
|
+
|
|
23
|
+
// Remove a tag
|
|
24
|
+
data.removeEntry(exif.constants.tags.ORIENTATION)
|
|
25
|
+
|
|
26
|
+
// Serialize into raw EXIF
|
|
27
|
+
const exifBytes = data.saveData()
|
|
28
|
+
// <Uint8Array>
|
|
22
29
|
```
|
|
23
30
|
|
|
24
31
|
## License
|
package/binding.c
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
#include <js.h>
|
|
4
4
|
#include <libexif/exif-data.h>
|
|
5
5
|
#include <libexif/exif-tag.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <string.h>
|
|
6
8
|
#include <stdint.h>
|
|
7
9
|
|
|
8
10
|
typedef struct {
|
|
@@ -145,6 +147,68 @@ bare_exif_get_entry_value(js_env_t *env, js_callback_info_t *info) {
|
|
|
145
147
|
return result;
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
static js_value_t *
|
|
151
|
+
bare_exif_remove_entry(js_env_t *env, js_callback_info_t *info) {
|
|
152
|
+
int err;
|
|
153
|
+
|
|
154
|
+
size_t argc = 2;
|
|
155
|
+
js_value_t *argv[2];
|
|
156
|
+
|
|
157
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
158
|
+
assert(err == 0);
|
|
159
|
+
|
|
160
|
+
assert(argc == 2);
|
|
161
|
+
|
|
162
|
+
bare_exif_data_t *data;
|
|
163
|
+
err = js_get_arraybuffer_info(env, argv[0], (void **) &data, NULL);
|
|
164
|
+
assert(err == 0);
|
|
165
|
+
|
|
166
|
+
int64_t exif_tag;
|
|
167
|
+
err = js_get_value_int64(env, argv[1], &exif_tag);
|
|
168
|
+
assert(err == 0);
|
|
169
|
+
|
|
170
|
+
ExifEntry *entry = exif_data_get_entry(data->handle, (ExifTag)exif_tag);
|
|
171
|
+
|
|
172
|
+
if (entry != NULL) {
|
|
173
|
+
exif_content_remove_entry(entry->parent, entry);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return NULL;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static js_value_t *
|
|
180
|
+
bare_exif_save_data(js_env_t *env, js_callback_info_t *info) {
|
|
181
|
+
int err;
|
|
182
|
+
|
|
183
|
+
size_t argc = 1;
|
|
184
|
+
js_value_t *argv[1];
|
|
185
|
+
|
|
186
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
187
|
+
assert(err == 0);
|
|
188
|
+
|
|
189
|
+
assert(argc == 1);
|
|
190
|
+
|
|
191
|
+
bare_exif_data_t *data;
|
|
192
|
+
err = js_get_arraybuffer_info(env, argv[0], (void **) &data, NULL);
|
|
193
|
+
assert(err == 0);
|
|
194
|
+
|
|
195
|
+
unsigned char *bytes = NULL;
|
|
196
|
+
unsigned int len = 0;
|
|
197
|
+
exif_data_save_data(data->handle, &bytes, &len);
|
|
198
|
+
|
|
199
|
+
js_value_t *result;
|
|
200
|
+
void *output;
|
|
201
|
+
err = js_create_arraybuffer(env, len, &output, &result);
|
|
202
|
+
assert(err == 0);
|
|
203
|
+
|
|
204
|
+
if (len > 0) {
|
|
205
|
+
memcpy(output, bytes, len);
|
|
206
|
+
free(bytes);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
|
|
148
212
|
static js_value_t *
|
|
149
213
|
bare_exif_destroy_data(js_env_t *env, js_callback_info_t *info) {
|
|
150
214
|
int err;
|
|
@@ -462,6 +526,8 @@ bare_exif_exports(js_env_t *env, js_value_t *exports) {
|
|
|
462
526
|
V("initData", bare_exif_init_data)
|
|
463
527
|
V("entry", bare_exif_get_entry)
|
|
464
528
|
V("entryValue", bare_exif_get_entry_value)
|
|
529
|
+
V("removeEntry", bare_exif_remove_entry)
|
|
530
|
+
V("saveData", bare_exif_save_data)
|
|
465
531
|
V("destroyData", bare_exif_destroy_data)
|
|
466
532
|
V("destroyEntry", bare_exif_destroy_entry)
|
|
467
533
|
#undef V
|
package/index.js
CHANGED
|
@@ -124,6 +124,14 @@ exports.Data = class EXIFData {
|
|
|
124
124
|
return new EXIFEntry(data)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
removeEntry(tag) {
|
|
128
|
+
return binding.removeEntry(this._handle, tag)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
saveData() {
|
|
132
|
+
return new Uint8Array(binding.saveData(this._handle))
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
destroy() {
|
|
128
136
|
if (this._handle === null) return
|
|
129
137
|
binding.destroyData(this._handle)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-exif",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "EXIF support for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
],
|
|
17
17
|
"addon": true,
|
|
18
18
|
"scripts": {
|
|
19
|
-
"format": "prettier . --
|
|
20
|
-
"lint": "prettier
|
|
21
|
-
"test": "bare test.js"
|
|
19
|
+
"format": "prettier --write . && lunte --fix",
|
|
20
|
+
"lint": "prettier --check . && lunte",
|
|
21
|
+
"test": "brittle-bare --coverage test.js"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"brittle": "^3.4.0",
|
|
35
35
|
"cmake-bare": "^1.1.2",
|
|
36
36
|
"cmake-ports": "^1.6.0",
|
|
37
|
-
"lunte": "^1.
|
|
37
|
+
"lunte": "^1.8.0",
|
|
38
38
|
"prettier": "^3.3.3",
|
|
39
39
|
"prettier-config-holepunch": "^2.0.0"
|
|
40
40
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|