summaryrefslogtreecommitdiff
path: root/tools/tiff2pdf.c
diff options
context:
space:
mode:
authorThomas Bernard <miniupnp@free.fr>2020-11-14 12:53:01 +0000
committerEven Rouault <even.rouault@spatialys.com>2020-11-14 12:53:01 +0000
commit7be2e452ddcf6d7abca88f41d3761e6edab72b22 (patch)
treef58aca03f17ccce7624b9873390266be1bfeaeac /tools/tiff2pdf.c
parent2e822691d750c01cec5b5cc4ee73567a204ab2a3 (diff)
downloadlibtiff-git-7be2e452ddcf6d7abca88f41d3761e6edab72b22.tar.gz
tiff2pdf.c: properly calculate datasize when saving to JPEG YCbCr
fixes #220
Diffstat (limited to 'tools/tiff2pdf.c')
-rw-r--r--tools/tiff2pdf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 719811ea..d0b0ede7 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -2087,9 +2087,17 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){
#endif
(void) 0;
}
- k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p);
- if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){
- k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p);
+#ifdef JPEG_SUPPORT
+ if(t2p->pdf_compression == T2P_COMPRESS_JPEG
+ && t2p->tiff_photometric == PHOTOMETRIC_YCBCR) {
+ k = checkMultiply64(TIFFNumberOfStrips(input), TIFFStripSize(input), t2p);
+ } else
+#endif
+ {
+ k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p);
+ if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){
+ k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p);
+ }
}
if (k == 0) {
/* Assume we had overflow inside TIFFScanlineSize */