singapore: the smallest big galery
home » forum » Feature Requests » Global re-index

You are not logged in.

#1 2006-10-17 07:34:02

Paul
Member

Global re-index

A global re-indexing feature would be marvellous (on the Tools page, perhaps?)... would save me going into each individual gallery to re-index newly-uploaded photos.

Offline

 

#2 2006-10-17 07:38:21

pavian
Moderator

Re: Global re-index

uhm its already there? Thumbnail generator..

Offline

 

#3 2006-10-17 18:10:56

Paul
Member

Re: Global re-index

That's not a re-index of the gallery. Suppose I delete a handful of photos via Telnet, and then click the web-based thumbnail generator - I still get thumbnails for the 'deleted' photos, and the deleted photo thumbnails still appear in my gallery. I'm looking for something that will go through galleries recursively, checking that photos still exist, checking for new photos, and modifying/deleting thumbnails if need be. A proper re-index.

Offline

 

#4 2007-01-12 08:16:23

aussy
Member

Re: Global re-index

Sure it is needed. I wrote a simple program on C doing exactly the same: recursive search in galleries and thumbnail recreation if needed. I use it, for example, when someone has uploaded a new galery (by ftp)

Offline

 

#5 2007-01-12 22:26:56

Paul
Member

Re: Global re-index

Would you mind posting that code? It may be easily ported to PHP, for a web-based script.

Offline

 

#6 2007-01-14 15:42:04

forty two
Member

Re: Global re-index

A global re-index i think is a needed tool as well.  I think if Aussy posts up the C code and it can get ported to PHP for a web based script that would greatly improve the gallery.  As well i'm currently working on having the ability to move images and their metadata from album to album via the admin @ http://sgal.org/forum/viewtopic.php?id=1842.  Anyone is more then welcome to help out, as I could use some guidance.  I'm trying to post code as I go along.

Offline

 

#7 2007-01-15 06:28:10

aussy
Member

Re: Global re-index

Here is the code. Please note that it is a scratch: only jpeg files are reindexed, only IM is used, and the path,the resolution and so on are hardcoded.


// reindex.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include <io.h>
#include <stdio.h>
#include <time.h>
#include <direct.h>

const char resolution[]="100x100";
const char thumb_dir[] ="_thumbs";
const char convert[]="c:\\bin\\convert";


void process_dir(void)
{

    struct _finddata_t c_file;
    struct _finddata_t thumb_file;
    struct _finddata_t c_dir;

    long hFile;
    long hThumb;
    long hDir;

    char thumb_name[256];
    char cmd[256];



    /* looking for jpeg files first */
    if( (hFile = _findfirst( "*.jpg", &c_file )) == -1L )
        printf("\n NO JPG files found");
    else
    {
     _mkdir(thumb_dir);
    do
    {
        printf( "\n %-12s %.24s  ",
                   c_file.name, ctime( &( c_file.time_write ) ) );

        sprintf(thumb_name,"%s\\%s-%s",thumb_dir,resolution,c_file.name);

        if( (hThumb = _findfirst(thumb_name,&thumb_file)) == -1L)
        {
            printf(" - thumbnail not found\n");
            sprintf(cmd,"%s \"%s\" -thumbnail %s \"%s\"",
                convert,c_file.name,resolution,thumb_name);
            printf(" - created new");
            system(cmd);
        }
        else
        {
            printf( " %-12s %.24s  ",
                        thumb_file.name, ctime( &( thumb_file.time_write ) ) );

            if(thumb_file.time_write > c_file.time_write )
                printf(" - valid");
            else
            {
                printf(" - thumbnail is old\n");
                sprintf(cmd,"%s \"%s\" -thumbnail %s \"%s\"",
                    convert,c_file.name,resolution,thumb_name);
                printf(" - refreshed");
                system(cmd);
            }
        }

        _findclose(hThumb);
   

    }while( _findnext( hFile, &c_file ) == 0 );

    _findclose( hFile );

    }

    /* directory search */
     if( (hDir = _findfirst( "*", &c_dir )) == -1L )
        printf("\n NO SUBDIRS FOUND");
    else
    {
        do
        {
            if( (c_dir.attrib & _A_SUBDIR) && !(c_dir.attrib & _A_HIDDEN ) )
            {
                if(c_dir.name[0]!='.' && c_dir.name[0] != '_')
                {
                    printf( "\n GO TO  %-12s ", c_dir.name );
                    fflush(stdout);
                    chdir(c_dir.name);
                    process_dir();
                    chdir("..");
                }
            }

        }while( _findnext( hDir, &c_dir ) == 0 );
    }
    _findclose( hDir );

}


int _tmain(int argc, _TCHAR* argv[])
{
    process_dir();
    printf("\n DONE!");
    return 0;
}

Offline