pnginfo: extract eXIf chunk data
This commit is contained in:
parent
16c6766e79
commit
fa15707d9b
@ -1,13 +1,14 @@
|
||||
SHELL = /bin/sh
|
||||
# libjq 1.6 lacks a pkg-config file, and there is no release in sight.
|
||||
CFLAGS = -g -O2 -Wall -Wextra `pkg-config --cflags $(deps)`
|
||||
# libjq 1.6 is required.
|
||||
CFLAGS = -g -O2 -Wall -Wextra `pkg-config --cflags $(deps)`
|
||||
LDLIBS = -ljq `pkg-config --libs $(deps)`
|
||||
|
||||
deps = libpng
|
||||
targets = pnginfo jpeginfo
|
||||
|
||||
all: $(targets)
|
||||
$(targets): info.h
|
||||
clean:
|
||||
rm -f $(targets)
|
||||
|
||||
|
1265
tools/info.h
Normal file
1265
tools/info.h
Normal file
File diff suppressed because it is too large
Load Diff
1246
tools/jpeginfo.c
1246
tools/jpeginfo.c
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,8 @@
|
||||
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
//
|
||||
|
||||
#include "info.h"
|
||||
|
||||
#include <png.h>
|
||||
#include <jv.h>
|
||||
|
||||
@ -143,12 +145,16 @@ extract_chunks(png_structp pngp, png_infop infop)
|
||||
if (png_get_iCCP(pngp, infop, &name, NULL, &profile, &profile_len))
|
||||
o = jv_object_set(o, jv_string("ICC"), jv_string(name));
|
||||
|
||||
// https://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html#C.eXIf
|
||||
jv set = jv_object();
|
||||
png_unknown_chunkp unknowns = NULL;
|
||||
int unknowns_len = png_get_unknown_chunks(pngp, infop, &unknowns);
|
||||
for (int i = 0; i < unknowns_len; i++)
|
||||
for (int i = 0; i < unknowns_len; i++) {
|
||||
set = jv_object_set(set,
|
||||
jv_string((const char *) unknowns[i].name), jv_true());
|
||||
if (!strcmp((const char *) unknowns[i].name, "eXIf"))
|
||||
o = parse_exif(o, unknowns[i].data, unknowns[i].size);
|
||||
}
|
||||
|
||||
jv a = jv_array();
|
||||
jv_object_keys_foreach(set, key)
|
||||
@ -227,7 +233,7 @@ error_png:
|
||||
fclose(fp);
|
||||
error:
|
||||
if (err) {
|
||||
o = jv_object_set(o, jv_string("error"), jv_string(err));
|
||||
o = add_error(o, err);
|
||||
free(err);
|
||||
}
|
||||
return o;
|
||||
|
Loading…
Reference in New Issue
Block a user