Bug 295548

Summary: ksnapshot silently saves files with unsupported extensions as PNG
Product: [Applications] kfile Reporter: Orion Poplawski <orion>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: cfeck, nate
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Orion Poplawski 2012-03-08 18:19:52 UTC
If you save a snapshot as file.pdf it does so without complaint but the file is a PNG image.  Would be nice if it warned about an unsupported image type.
Comment 1 Christoph Feck 2012-03-08 18:26:34 UTC
Does .pdf appear in the list of supported types?
Comment 2 Orion Poplawski 2012-03-08 18:28:06 UTC
(In reply to comment #1)
> Does .pdf appear in the list of supported types?

No.
Comment 3 Christoph Feck 2012-03-11 13:17:23 UTC
I am puzzled how this should be solved. Since ".pdf" is not listed as a supported file type, the file dialog does not know that .pdf is the extension of a different file type.

Let's say you try to save an image as "my.new.test". What should it do? Reject the file name, because it ends in ".test", which is not known as a file type?
Comment 4 Orion Poplawski 2012-03-12 18:11:40 UTC
I think it is up to your code to check that the file type returned by the save dialog is still valid.  It looks like you can use KFileDialog::currentMimeFilter() (http://api.kde.org/4.x-api/kdelibs-apidocs/kio/html/classKFileDialog.html#a2eeee39828dbff80b7bbe8c9ec9d112e) as one way to check.  It appears to be empty in I set .pdf as the exention, and "image/png" if I set .png.   digikam has it's own internal check:    m_savingContext.format = selectValidSavingFormat(imageFileSaveDialog->currentFilter(), newURL, autoFilter); and puts up an error if invalied.  Windows (microsoft office at least) simply tacks the appropriate extension back on so you would end up with filename.pdf.png.

I suppose it might be a nice enhancement to KFileDialog to handle this internally as almost every program will encounter this issue.
Comment 5 Nate Graham 2018-04-09 22:10:28 UTC
KSnapshot is an obsolete and unsupported product; please file a new bug if the same issue happens with Spectacle (KSnapshot's replacement).