| Register | Forget password
Tech - Reading a topic
<<  <  1  >  >>

Organize and version control digital photos with Subversion (advanced)

good(0) bad(0) view(7558) comments(0)
Wen Send a message to Wen Send an email to Wen
poster face
Level: ◆◆◆◆◇◇◇

If you have no idea what Subversion is, or how to install Subversion, or how to add photos to a Subversion repository, please read Organize and version control digital photos with Subversion (basic) first. Here we are going to discuss some advanced topics.

Recommended folder layout

Subversion has no restriction on the folder layout in the repository. What folder layout to choose is totally up to you. The Subversion documentation recommends creating a "trunk" and a "branches" folder at the root of the the repository. Here's a folder layout I use:

|  |-20070901
|  \-20080304
   |  |-20070901
   |  \-20080304

I keep the maximum-size photos in the "trunk" folder. When I need to resize or crop some photos, for example, for posting on my website, I do the converting job and then put the converted photos in the "branches" folder.

Move/Rename photos

Suppose you followed the instructions in Organize and version control digital photos with Subversion (basic) and created such a folder layout:


How do you convert this layout to the one recommended above? Here you need the "move" command. You can follow these commands:

cd \photo
svn mkdir trunk
svn mkdir branches
svn move 20070901 trunk\
svn move 20080304 trunk\
svn commit -m "move photos into trunk\"

The "mkdir" command is used for making a new folder. If you encounter an error committing the changes (the last command), try to run

svn update

then commit again.

You can also use the "move" command to rename files and folders. Don't forget to commit the changes to the repository.

Making branches

There's more than one way to do this. Here's my way to make a web posting branch:

  1. Make a copy from the trunk to the branches folder. Execute:

    cd \photo
    svn mkdir branches\web
    svn copy trunk\20070901 branches\web[/code]
  2. Convert all photos in D:\photo\branches\web\20070901. I use a PHP script calling ImageMagick to do this job. Here's my php script:

    $resDir = opendir(".");
    while (($strFile = readdir($resDir)) !== false) {
        if (is_dir($strFile)) continue;
        system("convert ".$strFile." -resize 520x520 ".$strFile);

    First make sure PHP CLI and ImageMagick are installed properly. Then put the php script in D:\photo\branches\web\20070901, and execute the script. The photos will then all be resized with the longer side 520px. You can also use another script language to achieve the same effect.

  3. Run "svn commit" to commit the changes to the repository.

Backup the photo repository

To backup the repository, use this command:

svnadmin dump --deltas file:///d:/repos/photo > D:\backup\photo.bak

Here "--deltas" is an option for saving disk space. D:\backup\photo.bak is the backup file.

Restore the photo repository from a backup file

Suppose you want to restore D:\backup\photo.bak to the repository D:\repos\photo_new. Execute:

svnadmin load file:///d:/repos/photo_new < D:\backup\photo.bak


Simply backup the repository and restore it somewhere else.


We show the above examples in order to demonstrate the usage of these Subversion commands:
svn mkdir (make a new folder)
svn move (move files/folders)
svn copy (copy files/folders)
svnadmin dump (backup a repository)
svnadmin load (restore a repository)

To totally master Subversion, you are recommended to read more on Version Control with Subversion.

Last edited by Wen at 2008-11-08 11:11:28

Posted at 2008-10-19 15:39:26
Tech - Reading a topic
<<  <  1  >  >>

Valid XHTML 1.0 | Valid CSS2 | WAI-A WCAG 1.0

Copyright 2005-2018 WEN'S Horizon [32/0.024]