Separate folderstructure for thumbs Separate folderstructure for thumbs
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Separate folderstructure for thumbs

Started by jehi, June 15, 2008, 10:12:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jehi

Hi,

I am seeking a solution for Coppermine, where:
1. Original pictures are readonly for the script
2. Resized pictures are stored in a separated folder structure to ease backup of originals.

If I am in the wrong forum, plz excuse and tell me where to go.

Regards,
Jesper

jehi

Hi,

After searching a bit more in the forums I found historical requests for more or less the same feature in the past. They where rejected with the question Why?

I can at least find three for me reasonable arguments for separated folder structures for original pictures and generated pictures as follows.
1. Sequrity reason, apache user can only read original pictures (if your sites admin user is hijacked they cant easily erase your pictures)
2. Backup reason, your backup script easily backup or rsync original pictures folder structure, the other can be regenerated (saves backupspace and simplify algorithm)
3. Directory structure for original pictures can be used for several different purposes (two different web pages or as in my case as a network disk on my Mac for picture shows in the living room).

Maybe other users of Coopermine which is a rich featured web gallery can follow up with there personal reasons for this fature with separate directory trees for originals and generated pictures.

Truly hope and awaits this feature which is a show stopper for me to go for Coppermine.

Regards,
/Jesper

just_some_guy

To create this it would require some extensive modifications, although it is possible. I agree that a folder structure like this would be very useful and more organized. To follow up your 3rd reason; if you do have plenty diskspace then you could easily add one line of code to copy() the fullsize uploaded image to another directory in order for you to use a media-manager type display. A backup script could be scripted to only backup/restore the fullsize images and then use those as a base to create thumbnails etc.

Tambien, Hablo EspaƱol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

jehi

Plenty of diskspace or not, I do not prefer a design of that kind. I have a image archive of 80GB+, growing every day. I have three different web-applications accessing the images so then I should use three different copies, not reasonable for me. Of course I could use a more inteligent backup solution to ignore the generated images, but the backup solutions is not only for the image archive and what about the other web-applications, should I implemnt filters in them too?

So as a system designer in software with 10+ year of experience I speak for a good system solution. Of course  a change of this kind will affect the source, but if I understand the implementation only in the upload and generation use cases. If there is no interest from the development team, please give me a few hints on how to implement it and pray for a bad summer.

Regards,
Jesper

boothy

Have you seen http://forum.coppermine-gallery.net/index.php/topic,16291.msg76058.html#msg76058 ?

I am in the process of testing locally a cpg which will have thumbs and normal pics away from the full size ones, so they can be protected by .htaccess easier.  This is what I have modded to achieve this.

Basically, in include/functions.inc.php you change get_pic_url to:

function& get_pic_url(&$pic_row, $mode,$system_pic = false)
{
        global $CONFIG,$THEME_DIR;

        static $pic_prefix = array();
        static $url_prefix = array();

if ( $mode == "thumb" )
{
$thumb_path = "thumbnails/";
}
if ( $mode == "normal" )
{
$thumb_path = "thumbnails/";
}

        if (!count($pic_prefix)) {
                $pic_prefix = array(
                        'thumb' => $CONFIG['thumb_pfx'],
                        'normal' => $CONFIG['normal_pfx'],
                        'fullsize' => ''
                );

                $url_prefix = array(
                        0 => $CONFIG['fullpath'],
                );
        }

return $thumb_path . $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);


in addpic.php, add:
$dir_name = dirname($pic_file) . "/";
$file_name = basename($pic_file);

// we create other directory that will follow the same structure than the album of original pictures
$dir_check = "thumbnails/albums/" . dirname($pic_file) . "/";

$dir_explode = explode("/", $dir_check);
$new_dir = "./";
foreach($dir_explode as $part_dir)
{
$new_dir = $new_dir . $part_dir ;
if(!is_dir($new_dir))
{
mkdir ($new_dir, 0744);
}
$new_dir = $new_dir . "/";
}
// end of additional lines


in include/picmgmnt.inc.php, replace the start of the resize_image function with:

function resize_image($src_file, $dest_file, $new_size, $method, $thumb_use)
{
    global $CONFIG, $ERROR;
    global $lang_errors;

$dest_file = "thumbnails/" . $dest_file;


Hope it works for you! :)

jehi

Hi,

It worked fine, BUT ....

When I delete pictures it deletes the originals but not the 'Normal' and 'Tumb'. I should like it th opposite way.

Have you fixed that patch as well, or shall I start going thrue it?

/J

boothy

Have a look at the link it my post, it explains how to do it.