Bug Hunting Session
Bug 98301 - Context menu "Save Image..." call of uno.saveGraphic is unclear that no conversion of image is provided
Summary: Context menu "Save Image..." call of uno.saveGraphic is unclear that no conve...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
5.1.0.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-01 12:28 UTC by Mike Saunders
Modified: 2019-06-13 14:47 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Draw doc with image that can only be exported in PNG format (251.96 KB, application/vnd.oasis.opendocument.graphics)
2016-03-01 12:28 UTC, Mike Saunders
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Saunders 2016-03-01 12:28:23 UTC
Created attachment 123105 [details]
Draw doc with image that can only be exported in PNG format

In the attached example.odg file, right-clicking on the flowchart diagram in the top-left and choosing Save Image pops up a dialog to save it.

You can choose other image format (SVG, GIF, JPEG etc.) but the image is always saved as PNG data.

Either it should be possible to save in other formats, or if only in the same format as embedded in the document, a choice of other formats should not be presented when saving.
Comment 1 V Stuart Foote 2016-03-01 15:47:52 UTC
On Windows 10 Pro 64-bit en-US with
Version: 5.1.1.2 (x64)
Build ID: fe4d9e69c82c6ee6db3c27cd5e2d47558afa80ac
CPU Threads: 8; OS Version: Windows 6.19; UI Render: GL; 
Locale: en-US (en_US)

Confirming. The context menu "Save Image..." call of .uno:saveGraphic does not convert the image, and that with its Export Image labeled dialog the "Save as" drop down selector will just assign a file extension--incorrectly to the image's format. No change of image format occurs.

The context menu "Save Image" dialog is incorrectly labeled as "Image Export" and should not offer save-as type formats other than the image format.  It affects PNG with Alpha transparency, and normal PNG bitmaps as well as JPEG bitmaps.

Would have to test a bit more for Save Image for other image formats inserted into Draw document--but believe the .uno:saveGraphic dialog called from context menu "Save Image" does not convert formats.

This is distinct from actual Export where, an image when selected ("Bitmap with transparency" showing in the status bar in this test case), performed from the File -> Export with "selection" and if desired with "Automatic file name extension" does perform conversion. To me, the export behavior is correct, but the Save Image <-> .uno:saveGraphic command/dialog needs adjustment.
Comment 2 Regina Henschel 2016-03-01 21:32:56 UTC
It is not so clear. For an embedded svg-image, the saved file format corresponds to the selected one. So conversion happens. But it is done with default settings.
Comment 3 V Stuart Foote 2016-03-02 00:17:53 UTC
(In reply to Regina Henschel from comment #2)
> It is not so clear. For an embedded svg-image, the saved file format
> corresponds to the selected one. So conversion happens. But it is done with
> default settings.

@Regina, your right of course.  But question then about what the filters are doing differently in the .uno:saveGraphic commands and why SVG would be handled differently than bitmaps.

What should the correct behavior be for the uno:saveGraphic? Since it should be fixed one way or the other for consistent UX.
Comment 4 QA Administrators 2017-03-06 15:43:23 UTC Comment hidden (obsolete)
Comment 5 Mike Saunders 2017-03-13 12:53:45 UTC
As per the request in Comment 4, I'm confirming this is still an issue in LibreOffice 5.3. Select image, right click -> Save, and the dialog provides a choice of image formats. The data will only be saved in the original format however, regardless of which format is chosen.
Comment 6 eisa01 2017-11-05 21:42:48 UTC
This is also an issue on Windows so setting OS to all to raise visibility.

This probably need UX input as well?
Comment 7 Heiko Tietze 2017-11-06 10:38:01 UTC
Simplest solution is to rename the function to 'Save as PNG' with a filter that does not provide other file types. Sounds like an easyhack to me.
Comment 8 Mike Saunders 2018-08-22 08:12:39 UTC
Just noting that this is still an issue in LO 6.1, that I experienced today. (Someone sent me a .odt file with lots of photos, and I wanted to save them as JPEGs, but they are always saved in PNG format, regardless of the filter chosen).

I agree with Heiko's suggestion to rename the menu entry to "Save as PNG...". If anyone has a code pointer, I can try to fix it myself and do my first EasyHack ;-)
Comment 9 Mike Saunders 2018-08-22 08:21:06 UTC
Actually it looks like the structure of the menu is defined here:

https://opengrok.libreoffice.org/xref/core/sw/uiconfig/swriter/popupmenu/graphic.xml

The specific line being:

<menu:menuitem menu:id=".uno:SaveGraphic"/>

Is the text defined in: https://opengrok.libreoffice.org/xref/core/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu

2174       <node oor:name=".uno:SaveGraphic" oor:op="replace">
2175         <prop oor:name="Label" oor:type="xs:string">
2176           <value xml:lang="en-US">Save Image</value>
2177         </prop>
2178         <prop oor:name="ContextLabel" oor:type="xs:string">
2179           <value xml:lang="en-US">Save...</value>
2180         </prop>
2181         <prop oor:name="Properties" oor:type="xs:int">
2182             <value>1</value>
2183         </prop>
2184       </node>

It looks to me like line 2179 needs to be changed. But I should do it myself and rebuild LO to test :-)
Comment 10 Heiko Tietze 2018-08-22 12:14:10 UTC
(In reply to Mike Saunders from comment #9)
> It looks to me like line 2179 needs to be changed. But I should do it myself
> and rebuild LO to test :-)

You become a fully qualified hack0r, resistance is futile. More about terminology is here https://design.blog.documentfoundation.org/2018/02/28/easyhacking-all-about-terminology/ - but you apparently found the right place.

After renaming you also need to adjust the dialog filter. But my skills are not sufficient to modify the filter after finding

* https://opengrok.libreoffice.org/xref/core/svx/sdi/svx.sdi#4359 => SID_SAVE_GRAPHIC
* https://opengrok.libreoffice.org/xref/core/sw/source/uibase/shells/grfsh.cxx#151 => GraphicHelper::ExportGraphic
* https://opengrok.libreoffice.org/xref/core/svx/source/core/graphichelper.cxx#183

(I expected something like "...Filter = [*.png|*.jpg|*.bmp]" but the file types are generated somewhere else in the dependency hell.)
Comment 11 Xisco Faulí 2018-09-22 02:42:21 UTC Comment hidden (obsolete)
Comment 12 Mike Saunders 2018-09-22 07:57:34 UTC
It's assigned to me, but I don't have the knowledge to follow up the "you also need to adjust the dialog filter" mentioned by Heiko in comment 10. So maybe leave it open in case someone else has an idea?
Comment 13 Xisco Faulí 2018-10-26 02:56:22 UTC Comment hidden (obsolete)
Comment 14 Mike Saunders 2018-10-26 06:53:03 UTC
It's assigned to me, but I don't have the knowledge to follow up, so no :-)
Comment 15 Xisco Faulí 2018-11-26 03:34:46 UTC Comment hidden (obsolete)
Comment 16 Mike Saunders 2018-11-26 09:53:36 UTC
It's assigned to me, but I don't have the knowledge to follow up, so no :-) Setting to NEW