[Digikam-devel] branches/stable/extragear/graphics/digikam/utilities/imageeditor

Gilles Caulier caulier.gilles at free.fr
Tue Apr 18 10:51:12 BST 2006


SVN commit 530992 by cgilles:

digikam from stable : image editor imlib2 interface: to detect image file format, we parse file extension in first, and in second, we parse file header.

This way is mandatory because some TIFF files are detected like RAW files by dcraw::parse method. 

Please, update svn and give me a feedback (:=)))...
 
CCMAIL:  digikam-devel at kde.org, frank at birnstiel.org, dudasg at freemail.hu

 M  +21 -0     imlibinterface.cpp  


--- branches/stable/extragear/graphics/digikam/utilities/imageeditor/imlibinterface.cpp #530991:530992
@@ -175,6 +175,27 @@
 {
     if ( filePath == QString::null )
         return NONE_IMAGE;
+
+    // In first we trying to check the file extension. This is mandatory because
+    // some tiff files are detected like RAW files by dcraw::parse method.
+
+    QFileInfo fileInfo(filePath);
+    if (!fileInfo.exists())
+    {
+        kdDebug() << k_funcinfo << "Failed to open file" << endl;
+        return NONE_IMAGE;
+    }
+    
+    QString ext = fileInfo.extension().upper();
+
+    if (ext == QString("JPEG") || ext == QString("JPG"))
+        return JPEG_IMAGE;
+    else if (ext == QString("PNG"))
+        return PNG_IMAGE;
+    else if (ext == QString("TIFF") || ext == QString("TIF"))
+        return TIFF_IMAGE;
+
+    // In second, we trying to parse file header.
         
     FILE* f = fopen(QFile::encodeName(filePath), "rb");
     



More information about the Digikam-devel mailing list