Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TIFF writer bug #3

Merged
merged 1 commit into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.github._4lex4.ScanTailor-Advanced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ modules:
path: com.github._4lex4.ScanTailor-Advanced.metainfo.xml.in
- type: patch
path: scantailor-qt5.15.patch
- type: patch
path: scantailor-tiffsave-fix.patch
buildsystem: cmake-ninja
config-opts:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
Expand Down
26 changes: 26 additions & 0 deletions scantailor-tiffsave-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From f6ae1624bf2cb55d1bd10a14d6215c2414633e32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hubert=20Figui=C3=A8re?= <[email protected]>
Date: Tue, 5 Jan 2021 15:23:48 -0500
Subject: [PATCH] Issue #164 - Fix TIFF saving when JPEG and posterized

---
src/core/TiffWriter.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/core/TiffWriter.cpp b/src/core/TiffWriter.cpp
index 0713e05ad..f84be661c 100644
--- a/src/core/TiffWriter.cpp
+++ b/src/core/TiffWriter.cpp
@@ -222,8 +222,10 @@ bool TiffWriter::writeBitonalOrIndexed8Image(const TiffHandle& tif, const QImage
}

if (image.format() == QImage::Format_Indexed8) {
- TIFFSetField(tif.handle(), TIFFTAG_COMPRESSION,
- uint16(ApplicationSettings::getInstance().getTiffColorCompression()));
+ uint16 compress = (photometric == PHOTOMETRIC_PALETTE) ?
+ COMPRESSION_LZW :
+ uint16(ApplicationSettings::getInstance().getTiffColorCompression());
+ TIFFSetField(tif.handle(), TIFFTAG_COMPRESSION, compress);
} else {
TIFFSetField(tif.handle(), TIFFTAG_COMPRESSION, uint16(ApplicationSettings::getInstance().getTiffBwCompression()));
}