From 1994f122cc29504862944cca1da1c5203c7e41eb Mon Sep 17 00:00:00 2001 From: yzrh Date: Thu, 31 Dec 2020 22:36:28 +0000 Subject: Decode JBIG and JPEG during HN conversion. --- src/jpeg.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/jpeg.c (limited to 'src/jpeg.c') diff --git a/src/jpeg.c b/src/jpeg.c new file mode 100644 index 0000000..4ea4d7f --- /dev/null +++ b/src/jpeg.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020-2021, yzrh + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include + +int +strinfo_jpeg_dim(int *jpeg_width, int *jpeg_height, + const char * restrict data, int data_size) +{ + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + + cinfo.err = jpeg_std_error(&jerr); + + jpeg_create_decompress(&cinfo); + + jpeg_mem_src(&cinfo, (unsigned char *) data, data_size); + + jpeg_read_header(&cinfo, TRUE); + + jpeg_calc_output_dimensions(&cinfo); + + *jpeg_width = cinfo.output_width; + *jpeg_height = cinfo.output_height; + + jpeg_destroy((struct jpeg_common_struct *) &cinfo); + + jpeg_destroy_decompress(&cinfo); + + return 0; +} -- cgit v1.2.3