Bug 145160

Summary: Writer Impress Draw Calc : the image compression form should select by default the former image format of each image
Product: LibreOffice Reporter: Jérôme <jerome.bouat>
Component: UIAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: enhancement CC: heiko.tietze, mentoring
Priority: medium Keywords: difficultyBeginner, easyHack, skillCpp, topicUI
Version: 4.2.0.4 release   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=77407
https://bugs.documentfoundation.org/show_bug.cgi?id=147456
https://bugs.documentfoundation.org/show_bug.cgi?id=98932
https://bugs.documentfoundation.org/show_bug.cgi?id=146929
https://bugs.documentfoundation.org/show_bug.cgi?id=107876
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 117085    
Attachments: image compression form

Description Jérôme 2021-10-15 19:46:50 UTC
Created attachment 175769 [details]
image compression form

When you change the image file format form a lossless format into a lossy format and vice versa, then the file size may increase and the image quality may decrease.

In the 7.2.1.2 version, the image compression form always select the jpeg format, even if the former file format is PNG.
Comment 1 Timur 2021-10-16 05:41:08 UTC
You filed bug 145160 and bug 145161 probably without searching existing bugs first. Please do and see if a duplicate, seems bug 119634.
Comment 2 Jérôme 2021-10-16 08:24:08 UTC
(In reply to Timur from comment #1)

This bug isn't a duplicate of bug 119634 because it isn't related to PDF export.
Comment 3 Jérôme 2021-10-17 16:43:59 UTC
See bug 77407 comment 9.
Comment 4 Heiko Tietze 2022-03-02 07:40:18 UTC
Duplicate of bug 146929? The settings will be remembered across the session.
Comment 5 Timur 2022-03-02 10:02:25 UTC
Writer was a duplicate of fixed bug 146929, but since Impress was also mentioned, I change to Impress and set New.
Comment 6 Jérôme 2022-03-02 19:34:49 UTC
This problem still appears with 7.2.5.2.0 version in Impress, Writer and Draw.

The issue is that the selected image format isn't by default the image format of the source image which has to be compressed.

If I open the image compression form, it should automatically change the selected output image format :
- if the former image type is png, then select png by default for the compressed image,
- if the former image type is jpeg, then select jpeg by default for the compressed image.

Next the user can change the image ouput image format before clicking on the "ok" button.
Comment 7 Timur 2022-03-02 19:46:48 UTC
(In reply to Jérôme from comment #6)
> This problem still appears with 7.2.5.2.0 version in Impress, Writer and
> Draw.
Did you not see that Writer was fixed, of course in master 7.4+? So 7.2 is not relevant for changing the title. Just wait.
Comment 8 Heiko Tietze 2022-03-03 13:44:47 UTC
Confirming that my patch isn't working with Impress, yet. Adding the missing piece.

Regarding the detection whether the source is JPEG or PNG and to use the correct algorithm: a) I wonder if the internal bitmap has any relation to the source; the compression algorithm can obviously used at both. But more relevant is b), if we want to remember user settings we cannot pick a default here.

So I make this ticket a duplicate and will submit a patch for the missing bit.

*** This bug has been marked as a duplicate of bug 146929 ***
Comment 9 Heiko Tietze 2022-03-11 09:53:46 UTC
Back to NEW following the discussion in bug 146929. The compression type should be excluded from what we remember as user choice and m_xLosslessRB or m_xJpegCompRB set active depending on the original format.

It's an easy hack, see 

svx/source/dialog/compressgraphicdialog.cxx
(and https://gerrit.libreoffice.org/c/core/+/129894)
Comment 10 Jérôme 2022-03-26 09:41:33 UTC
Images can be compressed in Calc too.
Comment 11 Jérôme 2022-03-26 10:01:05 UTC
In most cases, if you convert a jpeg image into a png image, you will inflate the image file size.
In a many cases the image file size will inflate if you convert a png image into a jpeg with a suitable quality, especially if the lossless image uses "artificial" colours (screenshot, ...).
Thus I mean this report isn't just an enhancement proposal. It proposes to avoid the ODF file size to increase when an image is "compressed" with this dialog.
Comment 12 Hossein 2022-10-07 11:24:23 UTC
@Ruslan:
In addition to changing the bug status to ASSIGNED, please also assign the bug to yourself. Now, I've done this for you.
Comment 13 Jérôme 2023-11-19 09:01:41 UTC
See bug #98932.

The form of compression must be retained if the old image used indexed colours :
- retain indexed colours if they were indexed,
- apply the user's global preferences if they were not indexed.