https://bugs.kde.org/show_bug.cgi?id=499241
--- Comment #9 from [email protected] --- I tried to work on this bug. For start, it is barely a bug, wrong extension is the fault of program or person who mismatched it. But if it can be fixed why not fix it. The bug happens with jpeg, because "image/jpeg" has specific thumbnail creator plugin: jpegthumbnail. Any other images are covered by imagethumbnail. Both plugins are in kio-extras repo. The bug can be easily fixed by editing kio-extras/thumbnail/jpegcreator.cpp:54 from QImageReader imageReader(request.url().toLocalFile(), "jpeg"); to QImageReader imageReader(request.url().toLocalFile()); So jpegthumbnailer will be able to process non-jpeg image in case of mismatch. QImageReader will autodetect actual image format instead of crashing. According to measurements and logically, it doesn't have any significant overhead. It may seem as improper solution, because the bug is caused by incorrect plugin choice due to incorrect mime detection. But correcting mime detection is not that simple, non obvious how to do it correctly and can have side effects. I will describe why. Mime detection happens in KIO::KFileItem. KFileItem, in case of delayed detection, which happens with thumbnails, prefers explicit detection by name. It checks content only if something is wrong with extension. If check happens, KFileItem uses QMimeDatabase with MatchDefault option. In default mode QMimeDatabase also prioretize extension, if there is nothing wrong with it. Changing mime detection to always match content will cause more mismatches, for example .docx will be detected as zip, and there're a lot of types that can be mismatched due to content match. Considering KFileItem is widely used, it would cause a lot of problems. I guess such detection is rather generally accepted, so that's not something we really want to touch in KFielItem or QMimeDatabase, if there're no weighty pros. So what can be done? If changing mime detection logic, it is most likey better to be placed at FilePreviewJob, if image is detected, it would be rechecked by content. Or handling plugin failure. If jpeg fails, it falls back to image. Or just remove one argument, so jpeg plugin could handle other images, if it has to. -- You are receiving this mail because: You are watching all bug changes.
