Bug 60684 - Images right-click save in wrong format as PNG in all modules
Summary: Images right-click save in wrong format as PNG in all modules
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: Other other
: high major
Assignee: Julien Nabet
URL:
Whiteboard: BSA target:7.1.0 target:7.0.0.2 targe...
Keywords: bibisected, bisected, dataLoss, regression
: 75786 81764 98301 107053 119830 130042 (view as bug list)
Depends on:
Blocks: Images
  Show dependency treegraph
 
Reported: 2013-02-11 18:53 UTC by Timothy Baldwin
Modified: 2023-10-16 09:53 UTC (History)
13 users (show)

See Also:
Crash report or crash signature:


Attachments
Save as PNG csaves a JPEG image with a .png extension (46.15 KB, image/png)
2019-10-28 11:45 UTC, Pedro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Baldwin 2013-02-11 18:53:33 UTC
Problem description: 

Steps to reproduce:
1. Create new Writer document.
2. Use Insert->Picture->From File to insert a JPEG image
3. Right click on picture.
4. Click on "Save Graphic".
5. Enter file name "test".
6. Choose the format PNG from the combo box  at the bottom right of the save dialog box.
7. Click "Save"

Current behaviour:
A JPEG file called "test.png" is saved.

Expected behaviour:
A PNG file called "test.png" is saved.

Running Libreoffice provided British English binaries on Debian Wheezy x86-64.
Operating System: Debian
Version: 4.0.0.3 release
Comment 1 Jorendc 2013-02-23 22:27:40 UTC
I can't confirm this using Mac OSX 10.8.2 and LibreOffice 4.0.0.3 release. Maybe Linux only?
Comment 2 Brenda Granados 2013-02-26 16:33:32 UTC
I can confirm this behavior using LibreOffice 4.0.1.0+ on Ubuntu 12.04. It wasn't clear to me how to determine that the file was not saved as a png. I tried to determine the picture properties by right clicking on the image and selecting Save Graphic. This shows me test.png, but still has "All Formats" listed the bottom right.

To see that the file was still actually a JPEG, I navigated to the folder via a terminal and used "file test.png", and it confirmed that it is actually still a JPEG. There's probably other ways of confirming file type, but that's what I did.

Thank you for reporting this bug!
Comment 3 Matthew Francis 2015-01-18 04:37:14 UTC
I can confirm this on OSX with 4.4.0.4. In addition, it's a regression.

Setting:
-> OS: All
-> Keywords: regression
-> Whiteboard: bibisected


Bibisect results from 43all:

# bad: [423a84c4f7068853974887d98442bc2a2d0cc91b] source-hash-c15927f20d4727c3b8de68497b6949e72f9e6e9e
# good: [65fd30f5cb4cdd37995a33420ed8273c0a29bf00] source-hash-d6cde02dbce8c28c6af836e2dc1120f8a6ef9932
git bisect start 'latest' 'oldest'
# bad: [e02439a3d6297a1f5334fa558ddec5ef4212c574] source-hash-6b8393474974d2af7a2cb3c47b3d5c081b550bdb
git bisect bad e02439a3d6297a1f5334fa558ddec5ef4212c574
# bad: [8f4aeaad2f65d656328a451154142bb82efa4327] source-hash-1885266f274575327cdeee9852945a3e91f32f15
git bisect bad 8f4aeaad2f65d656328a451154142bb82efa4327
# good: [369369915d3582924b3d01c9b01167268ed38f3b] source-hash-45295f3cdceb4c289553791071b5d7f4962d2ec4
git bisect good 369369915d3582924b3d01c9b01167268ed38f3b
# good: [6fce03a944bf50e90cd31e2d559fe8705ccc993e] source-hash-47e4a33a6405eb1b5186027f55bd9cb99b0c1fe7
git bisect good 6fce03a944bf50e90cd31e2d559fe8705ccc993e
# bad: [da317333e5675622f55c9dda17396c659af65320] source-hash-15af925c254f27046427de70a59011e2ac3d6bdb
git bisect bad da317333e5675622f55c9dda17396c659af65320
# good: [daa21bbd8c7b50e2ca1c2cbed0e39f0e7b5a1cb2] source-hash-6b11a18071254a443c8fe7e7b0b1c95b0f9fd35e
git bisect good daa21bbd8c7b50e2ca1c2cbed0e39f0e7b5a1cb2
# bad: [a08143f4bae3d6658dd756b42b6f343298d1f48c] source-hash-b7822657fa67e7265d07f5852057e975e9efae0d
git bisect bad a08143f4bae3d6658dd756b42b6f343298d1f48c
# good: [bb7d049cef53bd85904c58a28f6e33f49eb39664] source-hash-2168ee056253def18c43a6b13dbdfd0a992de2df
git bisect good bb7d049cef53bd85904c58a28f6e33f49eb39664
# good: [51103babf1aa8d305e361d30befb4562ed89cfe8] source-hash-786f730ea2608abaafdc656e2181d11e076b6648
git bisect good 51103babf1aa8d305e361d30befb4562ed89cfe8
# first bad commit: [a08143f4bae3d6658dd756b42b6f343298d1f48c] source-hash-b7822657fa67e7265d07f5852057e975e9efae0d
Comment 4 Matthew Francis 2015-01-18 04:37:42 UTC
*** Bug 75786 has been marked as a duplicate of this bug. ***
Comment 5 Matthew Francis 2015-01-18 04:37:58 UTC
*** Bug 81764 has been marked as a duplicate of this bug. ***
Comment 6 Matthew Francis 2015-01-18 12:49:23 UTC
This seems to have started at the below commit.

Adding Cc: to quikee@gmail.com; Could you possibly have a look at this? Thanks


commit 8c1aafe8c20b6de8e13b4ce0eb34bb1b1f04fc0f
Author: Tomaž Vajngerl <quikee@gmail.com>
Date:   Sat Jun 30 23:46:33 2012 +0200

    Change "Save graphic" and "Save picture as" to common code.
    
    Change-Id: Id860b3220bde3d43eec7c74711e6938e68d01d56
Comment 7 Robinson Tryon (qubit) 2015-12-13 11:16:21 UTC Comment hidden (obsolete)
Comment 8 gat 2016-03-19 19:18:05 UTC
I confirm that this still is an issue on Mac OS X with LibreOffice with 5.1.1.3.

$ file text.png
text.png: JPEG image data, JFIF standard 1.02

In addition, terms have changes so to reproduce use the following:
Insert -> Image...

Right click on the image -> Save image...
Comment 9 Xisco Faulí 2016-09-26 15:09:41 UTC Comment hidden (obsolete)
Comment 10 Buovjaga 2017-04-23 16:24:15 UTC
*** Bug 107053 has been marked as a duplicate of this bug. ***
Comment 11 Pedro 2017-04-23 23:47:09 UTC
This is NOT a Writer only problem as described in Bug report #107053

It affects the Save image function in ALL LibreOffice modules.
Comment 12 Pedro 2017-07-24 08:21:03 UTC
Update on this bug: in version 5.3.5.1 all images are now saved as PNG (which is better than saving all as JPEG).

Expected: save as the file format selected (e.g. if the user chooses TIFF then it should be saved as in TIFF format, not as a PNG with a .tif file name extension)
Comment 13 QA Administrators 2018-07-25 02:41:09 UTC Comment hidden (obsolete)
Comment 14 Pedro 2018-07-25 09:04:09 UTC
Yes, the bug still occurs in Version: 5.4.7.2
Other bugs surfaced while testing in 6.0.5
Comment 15 Thomas Lendo 2018-10-27 19:46:09 UTC
Still reproducible.
Although you choose png as save format, the file is still a jpg. You can see that when you open the saved image with an editor.

Version: 6.2.0.0.alpha1+
Build ID: 5d2ab49cbda1d7aea1019478abe0163e1f40a121
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: de-DE (de_DE.UTF-8); Calc: threaded
from today

For me, the importance of this bug is too low. An prominent command does not what the user expects.
Comment 16 QA Administrators 2019-10-28 03:29:11 UTC Comment hidden (obsolete)
Comment 17 Pedro 2019-10-28 11:45:35 UTC
Created attachment 155359 [details]
Save as PNG csaves a JPEG image with a .png extension

The problem still occurs using version 6.2.8

I disagree with the previous comment: Saving by default in a lossy format such as JPG is a bad option. At least save in a lossless format such as PNG or TIF

An easy way to verify the file type (regardless of the file extension) is to open the image in GIMP and go to Image, Image Properties (or press Alt+Enter)
Opening the attached file you will see "File Type: JPEG image"
Comment 18 Pedro 2020-02-11 09:57:43 UTC
(In reply to Thomas Lendo from comment #15)

> For me, the importance of this bug is too low. An prominent command does not
> what the user expects.

I understand now what you meant. The Importance needs to be raised. Maybe someone doing the triage can do that?
Added keyword dataLoss because saving as JPG instead of PNG causes information (and quality) loss.
Comment 19 eisa01 2020-02-15 18:06:46 UTC
*** Bug 98301 has been marked as a duplicate of this bug. ***
Comment 20 Timur 2020-02-24 08:40:25 UTC
*** Bug 130042 has been marked as a duplicate of this bug. ***
Comment 21 Julien Nabet 2020-02-24 10:05:01 UTC
Tomaz: taking a look at https://cgit.freedesktop.org/libreoffice/core/commit/?id=8c1aafe8c20b6de8e13b4ce0eb34bb1b1f04fc0f
the old methods SdGRFFilter::SaveGraphic and ExportGraphic are quite different, could it be a lead?

Meanwhile: let's increase a bit more importance since:
- it's a regression
- it happens in all envs
- it's not a corner case
Comment 22 AngelaAngie 2020-03-16 04:57:25 UTC Comment hidden (spam)
Comment 23 Tomaz Vajngerl 2020-03-27 09:52:56 UTC
(In reply to Julien Nabet from comment #21)
> Tomaz: taking a look at
> https://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=8c1aafe8c20b6de8e13b4ce0eb34bb1b1f04fc0f
> the old methods SdGRFFilter::SaveGraphic and ExportGraphic are quite
> different, could it be a lead?

Well, there were 2 way to do it. The way with XOutBitmap that was used in writer seemed to be the simpler one, so that's what I used. Probably SdGRFFilter::SaveGraphic and ExportGraphic would be a better choice.
Comment 24 Telesto 2020-05-24 10:24:02 UTC
*** Bug 119830 has been marked as a duplicate of this bug. ***
Comment 25 Telesto 2020-05-24 10:25:37 UTC
Regression introduced in range https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=786f730ea2608abaafdc656e2181d11e076b6648..b7822657fa67e7265d07f5852057e975e9efae0d

before it,

file /home/xisco/Baixades/test.bmp
/home/xisco/Baixades/test.bmp:
PC bitmap, Windows 3.x format, 640 x 426 x 24
Comment 26 Julien Nabet 2020-07-07 08:26:47 UTC
I gave it a try with:
https://gerrit.libreoffice.org/c/core/+/98239

(I'm not sure if I didn't miss something or if it's the right way to fix this).
Comment 27 Commit Notification 2020-07-09 07:11:26 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7272a2edf113f29edeb8987ce649f85b776d9d23

tdf#60684: graphic type content must correspond with graphic type extension

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 28 Commit Notification 2020-07-10 07:09:41 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/36962d9cc105d2c98889ee841438823fce090dfb

tdf#60684: graphic type content must correspond with graphic type extension

It will be available in 7.0.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 29 Julien Nabet 2020-07-10 08:15:21 UTC
Xisco: should we cherry-pick to 6.4 branch or it doesn't worth it?
Comment 30 Xisco Faulí 2020-07-10 08:46:59 UTC
(In reply to Julien Nabet from comment #29)
> Xisco: should we cherry-pick to 6.4 branch or it doesn't worth it?

well, it's true it's a regression and a high priority but, but it's been like that since 4.0 so I think we can live without having it in 6.4 branch.
OTOH, if you think it should be backported, go ahead a cherry-pick it.
Comment 31 Julien Nabet 2020-07-10 08:55:14 UTC
(In reply to Xisco Faulí from comment #30)
> (In reply to Julien Nabet from comment #29)
> > Xisco: should we cherry-pick to 6.4 branch or it doesn't worth it?
> 
> well, it's true it's a regression and a high priority but, but it's been
> like that since 4.0 so I think we can live without having it in 6.4 branch.
> OTOH, if you think it should be backported, go ahead a cherry-pick it.

Thank you for your feedback, let's try with https://gerrit.libreoffice.org/c/core/+/98456.
Comment 32 Commit Notification 2020-07-10 15:32:56 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/33d23bfd409783e5ba7279a7ef40f970e629e518

tdf#60684: graphic type content must correspond with graphic type extension

It will be available in 6.4.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 33 Commit Notification 2021-03-29 19:58:03 UTC
Aditya Pratap Singh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/869f3fa36e2c6306252cee43b244240d4024a242

tdf#60684 Add unit test

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.