pnginfo: extract eXIf chunk data
This commit is contained in:
parent
16c6766e79
commit
fa15707d9b
@ -1,13 +1,14 @@
|
|||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
# libjq 1.6 lacks a pkg-config file, and there is no release in sight.
|
# 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.
|
# libjq 1.6 is required.
|
||||||
|
CFLAGS = -g -O2 -Wall -Wextra `pkg-config --cflags $(deps)`
|
||||||
LDLIBS = -ljq `pkg-config --libs $(deps)`
|
LDLIBS = -ljq `pkg-config --libs $(deps)`
|
||||||
|
|
||||||
deps = libpng
|
deps = libpng
|
||||||
targets = pnginfo jpeginfo
|
targets = pnginfo jpeginfo
|
||||||
|
|
||||||
all: $(targets)
|
all: $(targets)
|
||||||
|
$(targets): info.h
|
||||||
clean:
|
clean:
|
||||||
rm -f $(targets)
|
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.
|
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "info.h"
|
||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include <jv.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))
|
if (png_get_iCCP(pngp, infop, &name, NULL, &profile, &profile_len))
|
||||||
o = jv_object_set(o, jv_string("ICC"), jv_string(name));
|
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();
|
jv set = jv_object();
|
||||||
png_unknown_chunkp unknowns = NULL;
|
png_unknown_chunkp unknowns = NULL;
|
||||||
int unknowns_len = png_get_unknown_chunks(pngp, infop, &unknowns);
|
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,
|
set = jv_object_set(set,
|
||||||
jv_string((const char *) unknowns[i].name), jv_true());
|
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 a = jv_array();
|
||||||
jv_object_keys_foreach(set, key)
|
jv_object_keys_foreach(set, key)
|
||||||
@ -227,7 +233,7 @@ error_png:
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
error:
|
error:
|
||||||
if (err) {
|
if (err) {
|
||||||
o = jv_object_set(o, jv_string("error"), jv_string(err));
|
o = add_error(o, err);
|
||||||
free(err);
|
free(err);
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
|
Loading…
Reference in New Issue
Block a user