This commit is contained in:
simon987 2020-04-15 19:09:37 -04:00
parent 0b0dcf89c0
commit ec129b84e8
7 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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 {

View File

View File

@ -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);
}