Bug 217598 - detect image type to save according to extension
Summary: detect image type to save according to extension
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: DImg-FileIO (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-06 15:53 UTC by Wolfram Quester
Modified: 2022-02-04 06:20 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 1.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfram Quester 2009-12-06 15:53:14 UTC
Version:           1.0.0~rc-1 (using KDE 4.3.2)
Compiler:          gcc amd64
OS:                Linux
Installed from:    Debian testing/unstable Packages

If I want to "Save As" in the image editor, and the filter selects jpeg images, I cannot type "bla.tiff" and the image is saved as tiff. It is still a jpeg with an irritating name.
This is especially bad, when I edit a 16Bit image, which is then automativally converted to 8 Bit without noticing.
In pre5, I could type whatever extension I wanted, and the file was saved properly, at least when the "All images" filter (which no longer exists) was selected.

For me, the proper behaviour would be to recognise the image type from the filename extension entered by the user.
Comment 1 Johannes Wienke 2009-12-06 16:07:26 UTC
There was a problem about the old behaviour: themoment the options that are special to a selected file type (like jpeg compression) are displayed directly inside the save dialog. If, eg. the dialog initially states tiff, you change the extension to jpeg in the filename and save the file with automatic file type detection based on the extension, you end up with unpredictable options for the generated jpeg, because you never saw the options for jpeg in the dialog.

I think there are two solutions to solve this problem if and automatic detection based on the filename is needed:

1. doing the automatic detection while typing the filename and adjusting the file type settings every time a new type is detected by the extension. But this could result in strange flickering of the dialog while typing.
2. Use two step procedure: First type the file name and after confirming the dialog show a separate window with file type specific options. This is the way gimp does it. I don't like it too much, because you always have to confirm two dialogs.
Comment 2 Wolfram Quester 2009-12-06 16:50:25 UTC
In the two-stage procedure you suggest, the second dialog is only necessary if the filter and the name from the first dialog contradict each other.

We could also simply attach the correct extension, so if I selected jpeg, but type bla.tiff, the file would be saved as bla.tiff.jpg. I aggree, this is ugly, but that way digikam would at least be able to open the file again, which it is not with the current behaviour.

At least I should be warned, if I try to save a 16Bit image in a 8Bit format.
Comment 3 Marcel Wiesweg 2009-12-06 22:47:59 UTC
I dont like the two-dialog approach.
The autodetection thing is how I would expect this to work; can the KDE file dialog do this?
Comment 4 Johannes Wienke 2009-12-06 22:49:40 UTC
I just tried a bit with the "options-while-typing" solution. It works better than I thought and we could use this one. The problem there is that this solution would completely ignore the filter selected.

My proposal would be to use the filename extension if the filter "all images" is selected and display the file format options immediately while typing after it is detected.

If any other filter is selected, use that format.

What do you think about this?
Comment 5 Johannes Wienke 2009-12-06 22:51:06 UTC
(In reply to comment #3)
> The autodetection thing is how I would expect this to work; can the KDE file
> dialog do this?

It's not much work. Could be don in half an hour for me. ;)

The only thing I see with my proposal above is that the filter "all images" should be changed to "all images (use extension for format)", but we're in the string freeze now... Can we break for this or should we wait with the string change after 1.0 release?
Comment 6 caulier.gilles 2009-12-06 22:54:51 UTC
I don't like twice dialog solution too..

You can break i18n if you please kde translators team sending a mail to the mailing list. also, i18n changes must be small of course.

Gilles Caulier
Comment 7 Johannes Wienke 2009-12-06 22:56:07 UTC
Ok, so do you think that solution I proposed is good?
Comment 8 caulier.gilles 2009-12-06 22:58:55 UTC
yes, it's fine for me...

Gilles
Comment 9 Johannes Wienke 2009-12-07 23:54:42 UTC
SVN commit 1060041 by jwienke:

Detect save file type based on file name of "all images" filter is selected. Otherwise use filter type.

BUG: 217598

 M  +129 -18   libs/widgets/common/filesaveoptionsbox.cpp  
 M  +47 -2     libs/widgets/common/filesaveoptionsbox.h  
 M  +13 -0     tests/CMakeLists.txt  
 AM            tests/filesaveoptionsboxtest.cpp   [License: GPL (v2+)]
 AM            tests/filesaveoptionsboxtest.h   [License: GPL (v2+)]
 M  +44 -51    utilities/imageeditor/editor/editorwindow.cpp  
 M  +5 -3      utilities/imageeditor/editor/editorwindow.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1060041
Comment 10 David Eriksson 2009-12-10 10:12:17 UTC
Under Windows the two step solution is needed since the Save as dialog is the native Windows dialog. Is it hard to do? I could try it myself if someone could give me some hints on where to start.
Comment 11 Johannes Wienke 2009-12-10 16:32:01 UTC
Gilles, what do you think? I never tried digikam on windows?
Comment 12 caulier.gilles 2009-12-10 16:35:36 UTC
Yes, under windows, Qt file dialog is used instead KDE filesave dialog. But i think it's a temporary solution...

Here Patrick can respond better than me about this situation...

Gilles