Bug 500870 - TIFF image file size increases after each overwrite
Summary: TIFF image file size increases after each overwrite
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (other bugs)
Version First Reported In: 5.2.9
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
: 502303 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-02-28 20:24 UTC by AgitatoArt
Modified: 2025-05-21 15:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description AgitatoArt 2025-02-28 20:24:39 UTC
SUMMARY
Each time a .tif file is overwritten, it bloats in size significantly. My most recently saved file bloated from 16.7 MB to over 100 MB after a few overwrites with minimal changes.

STEPS TO REPRODUCE
1. Export a TIFF image
2. Overwrite the same TIFF image via advanced export
3. Repeat step 2; the file size should increase with each overwrite

OBSERVED RESULT
The .tif file increases in size with each overwrite

EXPECTED RESULT
The .tif file should remain the same size with each overwrite
Comment 1 wolthera 2025-02-28 20:47:15 UTC
I can confirm.

And indeed, inspecting with a hex editor confirms my suspicion the data is appended onto the old version.
Comment 2 Nicholas LaPointe 2025-04-02 02:42:56 UTC
*** Bug 502303 has been marked as a duplicate of this bug. ***
Comment 3 Dmitry Kazakov 2025-05-21 15:28:29 UTC
Git commit 20ca858c2d9130b5a46fdf6af1a3290630bb4497 by Dmitry Kazakov, on behalf of Igor Danilets.
Committed on 21/05/2025 at 15:27.
Pushed by dkazakov into branch 'master'.

Fix TIFF file size bloating after each overwrite

Unlike the stdio library TIFF image files may not be opened for both
reading and writing; there is no support for altering the contents of a
TIFF file.
(https://libtiff.gitlab.io/libtiff/libtiff.html#basic-file-handling)
However, function TIFFFdOpen do not truncate the TIFF file before
the owerrite. When libtiff writes new data to existing file, the old
data is not deleted.

Solution:
Truncate the TIFF file before calling the function TIFFFdOpen.

M  +1    -1    plugins/impex/tiff/kis_tiff_export.cc

https://invent.kde.org/graphics/krita/-/commit/20ca858c2d9130b5a46fdf6af1a3290630bb4497
Comment 4 Dmitry Kazakov 2025-05-21 15:29:05 UTC
Git commit b4753f9d311814388f35177ea683e7ed7d72b165 by Dmitry Kazakov.
Committed on 21/05/2025 at 15:29.
Pushed by dkazakov into branch 'krita/5.2'.

Fix TIFF file size bloating after each overwrite

Unlike the stdio library TIFF image files may not be opened for both
reading and writing; there is no support for altering the contents of a
TIFF file.
(https://libtiff.gitlab.io/libtiff/libtiff.html#basic-file-handling)
However, function TIFFFdOpen do not truncate the TIFF file before
the owerrite. When libtiff writes new data to existing file, the old
data is not deleted.

Solution:
Truncate the TIFF file before calling the function TIFFFdOpen.


(cherry picked from commit 20ca858c2d9130b5a46fdf6af1a3290630bb4497)

Co-authored-by: Igor Danilets <danilec.igor@gmail.com>

M  +1    -1    plugins/impex/tiff/kis_tiff_export.cc

https://invent.kde.org/graphics/krita/-/commit/b4753f9d311814388f35177ea683e7ed7d72b165