PNG files cannot be added as tileset (on linux)
If a file has the extension .PNG it cannot be added as tileset image. Neither in the "missing tileset dialog" nor in the usual "add tileset dialog"
Are you trying to add a .png as if it was a .tsx file?
No. As normal tileset image.
Hmm, I can't reproduce that. Maybe a little more information about your environment?
Hm. You changed the title, but I really meant files with a .PNG so dot, uppercase PNG, not lowercase.
System is Gnome3, Fedora 23.
I can try to look into it somewhen to. but probably not the next days.
Ah, thanks for clearing that up! I'll try to reproduce it with a file with uppercase PNG as extension as well then.
Tiled 0.15.0, Xubuntu 14.04.1, XFCE Can't reproduce the problem. mytileset.PNG is added as well as any other images. Maybe this is some specific image or any file which has *.PNG extension is not added?
Hmm, I can also add such tilesets fine, but only when I type in their name, since they are not selectable in the file open dialog. So probably the problem is that it is doing a case-sensitive extension comparison. Is that the problem you mean, @Ablu?
In my case such files are even selectable from open file dialog with last repo version.

Hmm, interesting. May depend on the GTK or Qt version. I'm using Qt 5.5.1 and GTK 2.24.29.
May be the file was just renamed and is not a png.
Reproducible on:
Operating System: Linux Mint 22.1
Kernel: Linux 6.11.0-29-generic
Only files with lowercase extensions are available in the browse dialog. This is an environment specific issue and is out of the control of Qt.
diff --git a/src/tiled/utils.cpp b/src/tiled/utils.cpp
index 51abd7c6..43d5165a 100644
--- a/src/tiled/utils.cpp
+++ b/src/tiled/utils.cpp
@@ -46,6 +46,8 @@
#include <QProcess>
#include <QRegularExpression>
#include <QScreen>
+#include <QString>
+#include <QRegularExpression>
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0) && QT_VERSION < QT_VERSION_CHECK(6, 5, 1)
#include <QtCore/qapplicationstatic.h>
@@ -70,6 +72,29 @@ static QString toImageFileFilter(const QList<QByteArray> &formats)
namespace Tiled {
namespace Utils {
+static QString addUpperCaseExtensionsTo(const QString &filter)
+{
+ QString result = filter;
+ QRegularExpression re(QStringLiteral(R"(\*\.(\w+))"));
+ QRegularExpressionMatchIterator i = re.globalMatch(filter);
+
+ while (i.hasNext()) {
+ QRegularExpressionMatch match = i.next();
+ QString ext = match.captured(1);
+ QString extUpper = ext.toUpper();
+
+ const auto starDot = QStringLiteral("*.");
+ const auto space = QStringLiteral(" ");
+
+ if (ext != extUpper) {
+ QString oldPattern = starDot + ext;
+ QString newPattern = starDot + ext + space + starDot + extUpper;
+ result.replace(oldPattern, newPattern);
+ }
+ }
+ return result;
+}
+
/**
* Returns a file dialog filter that matches all readable image formats.
*
@@ -81,7 +106,7 @@ QString readableImageFormatsFilter()
auto imageFilter = toImageFileFilter(QImageReader::supportedImageFormats());
FormatHelper<MapFormat> helper(FileFormat::Read, imageFilter);
- return helper.filter();
+ return addUpperCaseExtensionsTo(helper.filter());
}
/**
@cannister-of-sparrows Interesting fix, but I'm wondering if we should really resort to such hacks. If the environment explicitly wants to consider "png" and "PNG" as different extensions, users would have this problem with all their files in all their applications and the only real options would be to:
- Get that file picker to not be case-sensitive, in case it's not intentional.
- The user needs to learn that file extensions are case-sensitive on their platform.
If this applies to your system, can you verify how other applications behave?
From the user perspective, they don't know about filter strings. The user only sees "Image files" of which, .PNG certainly is. There is no opportunity, on my system at least, to become aware of any filter string containing *.png.
Qt Creator itself exhibits the same behaviour when browsing for files to open. As do other applications. However, I don't think it is correct to blame the environment or the user.
Mime types, as here, allow case insensitive file discovery on my system.