Bug 101656 - imagegallery use irretating filenames foo.jpeg.jpeg for images
Summary: imagegallery use irretating filenames foo.jpeg.jpeg for images
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-HTMLGallery (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-17 03:01 UTC by Achim Bohnet
Modified: 2017-06-30 07:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.7.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Achim Bohnet 2005-03-17 03:01:28 UTC
Version:           0.1.1 (using KDE 3.4.0, Debian Package 4:3.4.0-0pre1 (3.1))
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-8)
OS:                Linux (i686) release 2.6.10-1-686

Hi Gilles,

I 'found' this old debian bug report:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=259346

There you are quoted:

---------- Forwarded message ----------
Date: Wed, 14 Jul 2004 18:21:32 +0200
From: Caulier Gilles <caulier.gilles@free.fr>
Reply-To: digikam-devel@lists.sourceforge.net
To: digikam-devel@lists.sourceforge.net
Subject: Re: [Digikam-devel] Bug#259346: digikamplugins: HTML album export
    adds a second ".jpg" to the generated filenames (fwd)

It's not a bug but a way for to export many images from a same Albums when
the filenames are the same (without extension), like this :

foo.png
foo.jpg
foo.tif

During the thumnailization, the file are renomed like this :

foo.png.jpg
foo.jpg.jpg
foo.tif.jpg

If we don't use this way, only one file are result from the
thumnailisation (the last one generated) :

foo.jpg corresponding to the foo.tif file. All other file are troncated...

Of course, like this the file name are confuse, and i will changed that like
this :

foo_png.jpg
foo_jpg.jpg
foo_tif.jpg

regards

Gilles
---------------------------------------------------


Looks like you forgot about it.  latest beta2 still
uses .jpeg.jpeg:

-rw-r--r--  1 ach ach 222189 2005-03-17 01:19 IMG_4222.JPG.jpg
-rw-r--r--  1 ach ach 389596 2005-03-17 01:20 dsc00200.jpg.jpg
-rw-r--r--  1 ach ach 270046 2005-03-17 01:20 dsc00219.jpg.jpg
-rw-r--r--  1 ach ach  76073 2005-03-17 01:20 firefox-missing-patches.png.jpg
-rw-r--r--  1 ach ach  62148 2005-03-17 01:20 getStringFromObj.jpg.jpg
-rw-r--r--  1 ach ach 179549 2005-03-17 01:20 img_2248.jpg.jpg


Achim
Comment 1 caulier.gilles 2005-03-17 06:33:38 UTC
I have unforget it. If you have some free time, please take a look in the code and provide a simple patch to correct this ploblem. 

Gilles
Comment 2 Angelo Naselli 2006-04-27 11:37:31 UTC
I have to check some duplicated here. 
I'm quite sure this problem is present in image gallery/html export 
batchprocess and cd archive (with html index).
I don't know if we can have a patch for the incoming release, but
I'm studying the problem.
Comment 3 Tom Albers 2006-05-28 17:38:04 UTC
This bug is reported against 'imagesgallery'. This plugin has been replaced by a new plugin called 'HTMLExport', which is written completely from scratch. This bug report will now be closed.
Comment 4 Angelo Naselli 2006-05-28 17:47:42 UTC
> This bug is reported against 'imagesgallery'. This plugin has been replaced 
> by a new plugin called 'HTMLExport', 
> which is written completely from scratch. This bug report will now be closed.  


Toma this bug I believe is present yet either in html export or 
in mpegecoder...

Angelo
Comment 5 Tom Albers 2006-05-28 18:03:44 UTC
reassigning
Comment 6 Angelo Naselli 2006-05-31 09:23:23 UTC
*** Bug 128035 has been marked as a duplicate of this bug. ***
Comment 7 Angelo Naselli 2006-06-02 15:21:01 UTC
according to bug #128035 (for IE)
Comment 8 Angelo Naselli 2006-06-02 16:02:15 UTC
Can someone check if it is really a problem for IE 
new html gallery plugin?
This plugin is changing the filename.ext into filename_ext.
That should work, the only thing I'm not sure is
as far as the page name concern e.g. filename_ext.jpeg.html,
so please check if it is a problem.
I found the problem reported here only for 
old html export plugin and cd archiver.
(about this last I'm going to release a patch soon)
Comment 9 Angelo Naselli 2006-06-02 21:25:54 UTC
Tested IMO the problem is only for cdarchive
Comment 10 Angelo Naselli 2006-06-02 21:32:40 UTC
SVN commit 547624 by anaselli:

Added webifyFileName (from html gallery)
and moved png file from old imagesgallery plugin
BUG: 101656
BUG: 128125

 M  +2 -0      Makefile.am  
 M  +39 -20    cdarchiving.cpp  
 M  +2 -0      cdarchiving.h  
 AM            gohome.png  
 AM            up.png  
 AM            valid-html401.png  


--- trunk/extragear/libs/kipi-plugins/cdarchiving/Makefile.am #547623:547624
@@ -25,3 +25,5 @@
 kipiimagebrokenpicdir = $(kde_datadir)/kipi/data
 kipiimagebrokenpic_DATA = image_broken.png
 
+kipiHTML401picdir = $(kde_datadir)/kipi
+kipiHTML401pic_DATA = valid-html401.png gohome.png up.png
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.cpp #547623:547624
@@ -38,6 +38,7 @@
 #include <qimage.h>
 #include <qtextcodec.h>
 #include <qtimer.h>
+#include <qregexp.h>
 
 // Include files for KDE
 
@@ -530,7 +531,7 @@
         KIPI::ImageCollection album = *it;
         kdDebug( 51000 ) << "HTML Interface for Album: " << album.name() << endl;
 
-        m_AlbumTitle      = album.name();
+        m_AlbumTitle      = webifyFileName(album.name());
         m_AlbumComments   = m_interface->hasFeature(KIPI::AlbumsHaveComments) ?
                             album.comment() : QString();
         m_AlbumCollection = m_interface->hasFeature(KIPI::AlbumsHaveCategory) ?
@@ -793,15 +794,15 @@
         {
             stream << "<tr>" << endl;
         }
-        
+
         QString   imgName = (*urlIt).fileName();
         QString   imgPath = (*urlIt).path();
         QFileInfo imgInfo(imgPath);
         QImage    imgProp = QImage(imgPath);
 
-        stream << "<td align='center'>\n<a href=\"pages/"  << imgName << ".htm\">";
+        stream << "<td align='center'>\n<a href=\"pages/"  << webifyFileName(imgName) << ".htm\">";
         kdDebug(51000) << "Creating thumbnail for " << imgName << endl;
-            
+
         d = new KIPICDArchivingPlugin::EventData;
         d->action = KIPICDArchivingPlugin::ResizeImages;
         d->starting = true;
@@ -809,13 +810,13 @@
         d->fileName = imgName;
         QApplication::sendEvent(m_parent, new QCustomEvent(QEvent::User, d));
         usleep(1000);
-            
+
         int valRet = createThumb(imgName, (*urlIt).directory(),
                                  imgGalleryDir, imageFormat);
-            
+
         if ( valRet != -1 )
         {
-            QString thumbPath("thumbs/" + imgName + extension(imageFormat));
+            QString thumbPath("thumbs/" + webifyFileName(imgName) + extension(imageFormat));
             stream << "<img class=\"photo\" src=\"" << thumbPath
                    << "\" width=\"" << m_imgWidth
                    << "\" "
@@ -1054,26 +1055,26 @@
     const QDir pagesDir(imgGalleryDir + QString::fromLatin1("/pages/"));
     const QDir thumbsDir(imgGalleryDir + QString::fromLatin1("/thumbs/"));
     const QString imgName(imgURL.fileName());
-    
+
     // Html pages filenames
 
     const QString pageFilename = pagesDir.path() +
                                  QString::fromLatin1("/") +
-                                 imgName +
+                                 webifyFileName(imgName )+
                                  QString::fromLatin1(".htm");
-    const QString nextPageFilename =  nextImgURL.fileName() +
+    const QString nextPageFilename =  webifyFileName(nextImgURL.fileName()) +
                                       QString::fromLatin1(".htm");
-    const QString prevPageFilename =  prevImgURL.fileName() +
+    const QString prevPageFilename =  webifyFileName(prevImgURL.fileName()) +
                                       QString::fromLatin1(".htm");
 
     // Thumbs filenames
 
     const QString prevThumb = QString::fromLatin1("../thumbs/") +
-                              prevImgURL.fileName() +
+                              webifyFileName(prevImgURL.fileName()) +
                               extension(m_imageFormat);
 
     const QString nextThumb = QString::fromLatin1("../thumbs/") +
-                              nextImgURL.fileName() +
+                              webifyFileName(nextImgURL.fileName()) +
                               extension(m_imageFormat);
 
     QFile file( pageFilename );
@@ -1240,7 +1241,7 @@
 
     // Create the thumbnails for the HTML interface.
 
-    const QString ImageNameFormat = imgName + extension(imageFormat);
+    const QString ImageNameFormat = webifyFileName(imgName) + extension(imageFormat);
     const QString thumbDir = imgGalleryDir + QString::fromLatin1("/thumbs/");
     int extent = m_thumbnailsSize;
 
@@ -1580,10 +1581,9 @@
    QDir dir(dirname);
    dir.setFilter ( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
 
-   Temp = "<directory name=\""
-          + EscapeSgmlText(QTextCodec::codecForLocale(), dir.dirName(), true, true)
-          + "\" >\n";
-
+      Temp = "<directory name=\""
+            + EscapeSgmlText(QTextCodec::codecForLocale(), dir.dirName(), true, true)
+            + "\" >\n";
    *stream << Temp;
    
    kdDebug( 51000 ) << "Directory: " << dir.dirName().latin1 () << endl;
@@ -1650,12 +1650,17 @@
    kdDebug( 51000 ) << "Adding Collection: " << collection.name() << endl;
 
    QString Temp;
+   QString collection_name;
+   if (m_useHTMLInterface)
+    collection_name = webifyFileName(collection.name());
+   else
+    collection_name = collection.name();
 
    Temp = "<directory name=\""
-          + EscapeSgmlText(QTextCodec::codecForLocale(), collection.name(), true, true)
+          + EscapeSgmlText(QTextCodec::codecForLocale(), collection_name, true, true)
           + "\" >\n";
    *stream << Temp;
-   
+
    KURL::List images = collection.images();
 
    for (KURL::List::iterator it = images.begin();
@@ -1853,6 +1858,20 @@
     return strReturn;
 }
 
+
+/**
+ * Produce a web-friendly file name 
+ */
+
+QString CDArchiving::webifyFileName(QString fileName) {
+  fileName=fileName.lower();
+  
+  // Remove potentially troublesome chars
+  fileName=fileName.replace(QRegExp("[^-0-9a-zA-Z]+"), "_");
+
+  return fileName;
+}
+
 }  // NameSpace KIPICDArchivingPlugin
 
 #include "cdarchiving.moc"
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.h #547623:547624
@@ -201,6 +201,8 @@
 
   void writeSettings(void);
   void readSettings(void);
+
+  QString webifyFileName(QString fileName);
 };
 
 }  // NameSpace KIPICDArchivingPlugin
** trunk/extragear/libs/kipi-plugins/cdarchiving/gohome.png #property svn:mime-type
   + application/octet-stream
** trunk/extragear/libs/kipi-plugins/cdarchiving/up.png #property svn:mime-type
   + application/octet-stream
** trunk/extragear/libs/kipi-plugins/cdarchiving/valid-html401.png #property svn:mime-type
   + application/octet-stream
Comment 11 caulier.gilles 2017-06-30 07:27:03 UTC
digiKam core has a new HTML Gallery tool which do not
have this problem.

Gilles Caulier