diff --git a/libscan/ebook/ebook.c b/libscan/ebook/ebook.c index 7929e85..bef52fd 100644 --- a/libscan/ebook/ebook.c +++ b/libscan/ebook/ebook.c @@ -83,6 +83,7 @@ int render_cover(scan_ebook_ctx_t *ctx, fz_context *fzctx, document_t *doc, fz_d if (err == 0) { unsigned char *tn_buf; size_t tn_len = fz_buffer_storage(fzctx, fzbuf, &tn_buf); + APPEND_TN_META(doc, pixmap->x, pixmap->y) ctx->store((char *) doc->uuid, sizeof(doc->uuid), (char *) tn_buf, tn_len); } diff --git a/libscan/font/font.c b/libscan/font/font.c index c1e09a0..dad74ce 100644 --- a/libscan/font/font.c +++ b/libscan/font/font.c @@ -221,6 +221,7 @@ void parse_font(scan_font_ctx_t *ctx, vfile_t *f, document_t *doc) { dyn_buffer_t bmp_data = dyn_buffer_create(); bmp_format(&bmp_data, dimensions, bitmap); + APPEND_TN_META(doc, dimensions.width, dimensions.height) ctx->store((char *) doc->uuid, sizeof(doc->uuid), (char *) bmp_data.buf, bmp_data.cur); dyn_buffer_destroy(&bmp_data); diff --git a/libscan/macros.h b/libscan/macros.h index 3361ed6..abef523 100644 --- a/libscan/macros.h +++ b/libscan/macros.h @@ -25,3 +25,9 @@ meta_str->key = keyname; \ strcpy(meta_str->str_val, value); \ APPEND_META(doc, meta_str) + +#define APPEND_TN_META(doc, width, height) \ + meta_line_t *meta_str = malloc(sizeof(meta_line_t) + 4 + 1 + 4); \ + meta_str->key = MetaThumbnail; \ + sprintf(meta_str->str_val, "%04d,%04d", width, height); \ + APPEND_META(doc, meta_str) diff --git a/libscan/media/media.c b/libscan/media/media.c index b96f79e..b46ea60 100644 --- a/libscan/media/media.c +++ b/libscan/media/media.c @@ -341,6 +341,7 @@ void parse_media_format_ctx(scan_media_ctx_t *ctx, AVFormatContext *pFormatCtx, avcodec_receive_packet(jpeg_encoder, &jpeg_packet); // Save thumbnail + APPEND_TN_META(doc, scaled_frame->width, scaled_frame->height) ctx->store((char *) doc->uuid, sizeof(doc->uuid), (char *) jpeg_packet.data, jpeg_packet.size); av_packet_unref(&jpeg_packet); diff --git a/libscan/scan.h b/libscan/scan.h index 1bfd682..5553d3b 100644 --- a/libscan/scan.h +++ b/libscan/scan.h @@ -74,6 +74,7 @@ enum metakey { MetaExifDateTime = META_STR(23), MetaAuthor = META_STR(24), MetaModifiedBy = META_STR(25), + MetaThumbnail = META_STR(26), }; typedef struct meta_line { diff --git a/test/.gitkeep b/test/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/test/main.cpp b/test/main.cpp index c0f7682..d325c30 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -131,7 +131,7 @@ TEST(TextMarkup, Xml1) { parse_markup(&text_500_ctx, &f, &doc); ASSERT_NEAR(strlen(get_meta(&doc, MetaContent)->str_val), 500, 4); - ASSERT_TRUE(strstr(get_meta(&doc, MetaContent)->str_val, "BMP:𐌈") != nullptr); + ASSERT_TRUE(strstr(get_meta(&doc, MetaContent)->str_val, " BMP:𐌈 ") != nullptr); cleanup(&doc, &f); }