Bug 131116 - Image compression should not increase resolution/filesize for already small images
Summary: Image compression should not increase resolution/filesize for already small i...
Status: RESOLVED DUPLICATE of bug 132657
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
Hardware: All All
: medium trivial
Assignee: Not Assigned
Depends on:
Blocks: 34133 Image-Compression
  Show dependency treegraph
Reported: 2020-03-04 09:37 UTC by Justin L
Modified: 2020-06-02 09:07 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:
Regression By:

tdf131116_compressionIncreases.odt: 26.9K sized document with 96dpi image (26.32 KB, application/vnd.oasis.opendocument.text)
2020-03-09 04:52 UTC, Justin L

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2020-03-04 09:37:56 UTC
Image compression appears to be more accurately a "resize" rather than a compression. The default compression value is 300dpi (in LO 7.0), and for an image with a smaller DPI already, it will expand the image to 300dpi, increasing the filesize for no apparent benefit.  I can't really think of a reason why anyone would want to force a reverse compression, so probably it should just do nothing in this case. This will especially be important when <hopefully> there will be option to compress all images in the document.

When used interactively, it could be argued that the user has all the information they need to determine whether or not to compress. True enough for a knowledgable user, but there can probably be some improvements here. One possibility would be to set the default to min(currentViewsizeDPI, 300) [an interesting easyhack?]. The other option would be to add a (by default enabled) checkbox to only compress. 

Using attachment 131240 [details] from bug 83734#c6, the first picture is at an effective 96dpi at it's current view size. Compressing that image (using the default DPI of 300) increases the filesize of the image and of the entire document.

I think this has always been true, but recently the default changed from 96 to 300. 300 seems like a good default in general, but it will expose this anti-compression problem more easily.

svx/source/dialog/compressgraphicdialog.cxx would be the place to start looking at this. Getting the currentViewsizeDPI could be a bit tricky, so lots of different image types and situations should be tested.
Comment 1 Geoff 2020-03-07 17:15:37 UTC
This behavior is not uncommon with compression in general. It's common that small files will increase in size in programs like ZIP, etc. due to the addition of decoding information.

Updated to "trivial" status as this is an edge case that most would not be fastidious enough to be concerned with.
Comment 2 Justin L 2020-03-09 04:52:20 UTC
Created attachment 158503 [details]
tdf131116_compressionIncreases.odt: 26.9K sized document with 96dpi image

This document will triple in size when the image is compressed using all defaults (300dpi, view width/height). Compression should never increase the pixel width/height of an image.

To exaggerate, compress to 1200dpi, and the filesize grows to more than 700k.
Comment 3 Justin L 2020-05-14 15:16:27 UTC

*** This bug has been marked as a duplicate of bug 132657 ***