Spectacle - Heic saved with PNG extension (causes other problems)

when taking screenshot by Spectacle it is saved with PNG extension, while the actual format is HEIC.
Spectacle 6.5.3 \ QT 6.10 \ Arch Linux

Some web results said it was fixed in 2018, but it isn’t.

reproduce:

$ spectacle -nbfo screenshot.png
$ file screenshot.png
screenshot.png: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile

I’ve updated my system several times in the past year, and this bug still exists.

It causes several problems (programs crash, image viewers can’t show it, user must do extra step) is most of the other programs rely on the extension, and fail opening it. For example, “Capture2text” → uses Pillow → ImageGrab → which uses Spectacle → and crashes due to this mismatch.

Is it my fault?

what is the problem?

the -o tells it to name the file .png but does not specify the file format

what does it say in /.config/spectaclerc

under the [Save] category for

defaultSaveImageFormat=

This works fine on Fedora (Qt 6.10.0, Plasma 6.5.2), so it is at least not generally broken.

$ spectacle -nbfo screenshot.png
$ file screenshot.png 
screenshot.png: PNG image data, 1920 x 1080, 8-bit/color RGBA, non-interlaced

The default format is set to JPG for me.

i would then try your arch install with a new user and if the issue persists file a bug report at bugs.kde.org under the plasma 6.5.3, spectacle product.

does the same thing happen when using the GUI or is this just a command like issue?

if the new user works as expecte, then you might try deleting your .cache folder and then changing the spectacle default away from PNG to some third format and see what the result is after a relog.

@skyfishgoo my spectaclerc exists bt there is no mention of the string “format”. Under [save] it only has last locations of files and folders.

Yes! The same exact problem happens with the GUI.
(strange -because my original post mentioned that. + The new UI don’t allow to edit my post :frowning:

@jbb please define “works fine”:

  1. when you specify “.png” extension, what is the file’s format?
  2. When you specify “.jpg” what’s the actual file format?
  3. If you don’t specify an extension, and choose a different file type, does it saves in the specified format and adds the corresponding extensions?

(in my case, none of them happens. )

indeed,

Under a new user, the behavior was correct (i.e. saved screehshot with the same file format as specified).

So back to my original user,:

  • I deleted ALL my cache files & folder under ~/.cache
  • I copied the ~/.config/spectaclerc from the new user “as is” from the new user

but the problem remained:

  • i still see “Image” filetype (in addition to all other file types).
  • when I choose PNG or WEBP file format, spectacle is always saving it as HEIC, regardless i choose extension/type PNG.

BUT!

  • it saves AVIF in actual AVIF format
  • the exact same problem & symptoms happens wen I “Save As” in GWENVIEW
  • I noticed 2 relevant errors / warnings when running Spectacle via console:

kf.kio.filewidgets.kfilefiltercombo: KFileFilterCombo::setCurrentFilter: Could not find file filter KFileFilter(MIME patterns: QList("image/jpeg") Fil
e patterns: QList() label: "image")
kf.kio.filewidgets.kfilefiltercombo: KFileFilterCombo::setCurrentFilter: Could not find file filter KFileFilter(MIME patterns: QList() File patterns:
QList("*.heif", "*.jfif", "*.jpe", "*.jpeg", "*.jpg", "*.png", "*.webp") label: "image")

i don’t know what to do from here

i consulted now with AI, which told me about the same bug in plasma 5.
But my Plasma is version 6.

KDE Plasma Version: 6.5.3
KDE Frameworks Version: 6.20.0
Qt Version: 6.10.0

I have re-built the mime type DB. the problem persistes (with gwenview & spectacle).

so there is no line for

[Save]

defaultSaveImageFormat=PNG

just add the line then, or change the default from the GUI and it should add the line for you.

if this still does not work you have bigger issues, but it looks like you rc file just got corrupted somehow and that line was deleted.

as a test you could rename your rc file and relog, and a new one should get created with all the defaults populated… if this line still does not show , then that is an issues with your distro.