Skip to content


Migrating from Gallery3 to Piwigo

As I posted a while back, they killed Gallery3. And finally I found the time to move (also I was getting annoyed of restraining myself from posting more pictures on the outdated software). Here are some pointers I would have liked to have for the migration :

First, in gallery3 it was okay to drop pictures in no album, in the root folder. In Piwigo, I believe it is NOT possible, and at least the migration script will ignore pictures left in the root folder. So before you make the switch, you should create a new album and put the pictures from the root folder into it. Or just take the time to finally sort those pictures 😉
While you’re there, check if you don’t have picture file names with quotes in them, as Piwigo doesn’t support that (and anyway you just shouldn’t use that kind of characters in file names). From the comments, it looks like ampersand (&) is bad voodoo too.

After that, it’s mostly straightforward:
– download Piwigo. I used the “package” but I suppose the “webinstall” works just as well
– install it following the instructions there
– once Piwigo is installed go to the administration panel, then to Plugins > Manage, then to the “Other plugins available” tab and install the plugin “Menalto2Piwigo”
– once Menalto2Piwigo is installed, go to Plugins > Menalto2Piwigo, and follow the instructions:
* step 1) Copy the content of g2data/albums (Gallery2) or var/albums (Gallery3) into [your piwigo folder]/galleries
* step 2) Go to Tools > Synchronize. At this step, you can have an error “PWG-UPDATE-1” when trying to import some files. It is caused by “forbidden” characters in file names, like spaces. Fortunately, the list of allowed characters can be configured: to do so, copy include/config_default.inc.php as local/config/config.inc.php, then locate $conf['sync_chars_regex']. It’s a regex of allowed characters, just add there the characters you need. For instance, I just needed to add spaces so my new line is $conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_. ]+$/';. See this forum thread if you need more details.
* step 3) Submit the form on the page: means obviously you need to put the parameters of your gallery3 database in there (screenshot)
* step 4) Install and activate plugins Extended Description: I’m not sure how useful it is but I did it anyway and it doesn’t seem to do any harm.

And voilà, migration complete, although you might want to check for corrupted characters if your database encodings don’t match (my Gallery3 was non-UTF-8 while my Piwigo is UTF-8, I lost quite a few French characters in the move :().

A little complement now: I had some ads and stat tracking (Piwik) code on my Gallery 3, here is how I added them back. Also by default Piwigo will expose your e-mail address on your gallery, not cool so we’ll deal with that too.

I put my ad code in the header, and actually I didn’t need to edit code for these as I found the subheader was a decent place to put them. In the admin panel, go to Configuration > Options, and then in the first tab you have a “Page banner” section where you can put HTML code, like:
<iframe data-aa='348' src='//ad.a-ads.com/348' scrolling='no' style='width:320px;height:50px;border:0px;padding:0;overflow:hidden;margin-left:20px;' allowtransparency='true'></iframe>
<iframe data-aa='348' src='//ad.a-ads.com/348' scrolling='no' style='width:320px;height:50px;border:0px;padding:0;overflow:hidden' allowtransparency='true'></iframe>

If you prefer to move it around a bit, you can probably find a good fit placing your ad code directly inside themes/default/template/header.tpl.

I put my stat tracking code in the footer, and that’s where the e-mail address is too. The file to edit is themes/default/template/footer.tpl.
For the e-mail, locate the section with “if isset($CONTACT_MAIL)”, and comment the block you want to remove with {* (that’s the comment start) and *} (that’s the comment end). NB: note the comment above saying you shouldn’t remove the “Powered by Piwigo” part, so make sure you don’t comment out too much!
For the stat tracking, you know the drill: just before </body>, as usual, so you can put your code just a few lines above the end of the file.
Last note: we edited the default theme, which means if you configure your gallery to use another theme, well you need to edit that theme instead.

…and that’s all, congrats on moving! I must say I found gallery3 smoother (even though I’m definitely not a design addict), but sticking to unmaintained software is bad, so…

Update: many customizations can be done using plugins

@plegall on Twitter pointed out that most of my above customizations can be done without touching the code but by using plugins:
– to remove the e-mail in footer, plugins “Contact Form” + “Protect Notification”
– to add Piwik or *cough* Google Analytics stats, plugin “Statistics”
– to add the regex to the config file, plugin “LocalFiles Editor”, and also note that, of course, you can limit the content of your modified config.inc.php to the values that you did modify

Update (2018-07-24): where is the database configuration stored?

I’m currently migrating to a new server, and one thing that drove me crazy is that I spent an indecent amount of time looking for my Piwigo database password (I use random passwords that are unique per-application and that I don’t store anywhere, except where it’s required in the application). The Piwigo forums were not helpful, possibly because the search is, let’s say, hard to get working right 😀 So in the end I just downloaded all my Piwigo installation and opened it locally in Visual Studio Code, which provide a nice search that made it easy to find where my database name was stored, which, obviously, was kind of next to the password.

Long story short, the database credentials are stored in local/config/database.inc.php. Why the hell the obvious “config” folder was hidden away in the goddamned “local” folder is beyond my understanding. But at least now I’ll know it’s there.

Posted in multimedia, open source.


16 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Sue Young says

    Thank you so much for this post – I found is invaluable in transferring my Gallery 3 to Piwigo. I am having one issue and wondering if you found this true with your transfer. I cannot delete any of the albums I transferred. Instead of the choice to delete there is a menu item “synchronise “, which does not see to do anything when I run it. Do you have the same problem.?

    • patheticcockroach says

      Well spotted. I had noticed this “synchronize” button but didn’t pay much attention to it nor linked it to the albums/categories being imported ones. Note sure of what it’s supposed to do either…
      I guess you could try to delete them manually in the database (perhaps after emptying them first? – and making a backup of course ^^). They seem to be located in the “categories” table.

  2. Sue Young says

    Thank you for your reply – I think I am narrowing this down.

    From http://piwigo.org/doc/doku.php?id=user_documentation:albums_management
    I found
    “If you use the FTP + synchronization method to add photos in your Piwigo gallery, then you have some physical albums.”
    So I am thinking synchronization seems to “confirm” the photo’s physical locations to the database

    And here: http://piwigo.org/doc/doku.php?id=user_documentation:learn:add_picture
    has a bit of an explanation of synchronization and I think it was here that I found:
    “No flexibility to move/rename your album: if you physically move your pictures/directories, all the data associated (comments, ratings..) are lost during the next synchronization.”

    And then I also had posted here: http://piwigo.org/forum/viewtopic.php?pid=167154#p167154 where the reply to this question was:
    “I never tried but i don’t think you can delete physical albums and photos. Only virtual.
    Delete them from ftp and resynchronize , or convert physical to virtual.”

    So it appears that files that are uploaded via FTP are handled differently than those uploaded via the program or plugin in and you can’t delete them through the admin section.

    I think the suggestion of the Extended Description plug in is there was something in there about hiding albums etc. Maybe that is why it is “suggested.”

    I hope this makes sense and is helpful to others.

    Sue

    • patheticcockroach says

      Yes, the migrated pictures and albums are in different folders (“galleries” instead of “upload”). I’m not really sure how those are handled globally, but I believe you should be able to move them around manually, as full paths (relative to Piwigo’s root folder) are stored in the “images” table (“path” field).

      I’m still pretty confident there’s a way to delete those manually, but it would involve removing files via FTP or equivalent plus editing the database directly.
      My guess would be simply:
      – for individual pictures, remove the entries in the “images” table + the matching files
      – for albums, first remove all their pictures, then remove the album entry in the “categories” table + the matching folder in the “galleries” folder

      “So I am thinking synchronization seems to “confirm” the photo’s physical locations to the database”
      => Yes it makes sense

      Also, I certainly wouldn’t use the FTP + sync method except for the initial migration (and I didn’t use it indeed). As I understand it, Piwigo is the happiest when you update a picture through the admin interface: it will then store the file in a place with a name based on the upload date & time, and store whatever album placement you wish only in the database. Makes sense, this way you never have to bother about moving around your picture files.

      About the “Extended Description” plug in, I really don’t remember, but I believe it had something to do with either the descriptions of my albums or the descriptions of my pictures. Maybe I should just try to disable it and see what happens… One day, when I have more time, maybe 😉

  3. Garfield says

    Thank you also very much for your post.

    I’m trying to migrate gallery2 to piwigo. Everything worked until step 2, I see albums and photos, but no album descriptions (which I guess should be migrated according the perl script from dschwen) and the sorting is wrong.
    Now I’m stuck on step 3: on which page is the form to fill out the parameters of the old database (which should contain album descriptions) ?

    Thank you in advance.

    • patheticcockroach says

      Hm, maybe the difference in step 2 comes from the fact that you’re migrating from Gallery 2 and not Gallery 3.

      My steps here are comments on the steps described in the Menalto2Piwigo migration page. The form in step 3 is the form that’s located on this same page (yourpiwigo.url/admin.php?page=plugin-menalto2piwigo)

      Screenshot here: https://img.patheticcockroach.com/01/menalto2piwigo.png

      • Garfield says

        Thank you for your explanation. So there was my mistake… I followed your steps, but not the steps in the actual plugin.

        Sadly, filling in the form seems to make no difference. There still are no album descriptions. Well, that’s now a case for someone with more knowledge than mine…

      • patheticcockroach says

        Yeah, sorry I can’t be of more help, you’ll probably want to find someone who did the migration from Gallery2, or maybe check the bugtracker for the Menalto2Piwigo plugin, see if people are talking about that issue.

      • Garfield says

        Thank you again for your help. I now found the support forum, which solved my problem: the old files and photos necessarily need to stay in the gallery2 folder on the webserver. Otherwise, the album and photo descriptions can’t be migrated.

        Not helpful, that Filezilla seems only be able to cut, but not to copy. That’s why I did it wrong.

        Thank you again, your posting really was helpful.

  4. Al Scot says

    Thankyou so much
    I had to add the whole line $conf[‘sync_chars_regex’] = ‘/^[a-zA-Z0-9-_. &+()]+$/’;
    to
    local/config/config.inc.php (notice the additional &+()

    I had to search for “extended” ( EXTENDED DESCRIPITION ) under to install it.

  5. Ken says

    Thanks for this how-to.
    I migrated a bunch of albums from Gallery3 by copying the folders and synchronizing, then running Menalto2Piwigo. But it seems to stuff up with duplicate filenames even when they are in different directories.
    The image files are in the relevant directories, the photo names are displayed, just can’t find the photos! -Only a problem where filenames are duplicates. Grrrrr.

  6. Ken says

    Ok, I managed to get the ‘hidden’ photos to show.
    The problem was with album directory names containing ‘&’. Not all of them, but some.
    So I renamed the albums to remove & in both the galleries directory and in Gallery3, then re-synchronised and re-imported the G3 data with Menalto2Piwigo.
    (I had added & to [‘sync_chars_regex’]. Have now removed it.)

  7. Ken says

    And I ‘d like to add that running Menalto2Piwigo multiple times is not a good idea.
    -I had to manually remove a lot of duplicated comments. (Might be more duplication I haven’t noticed yet.)

  8. Tim Chuma says

    I did try this but for some reason my gallery3 install has way too many galleries for it to work.

    Also it kept spitting out errors about the names of galleries and special characters even with all the regex and filters I used to fix it.

    I struggled on for years with no support and had to get the Webhost tech support to fix a recent technical issue.

    I will probably just leave all my old photos on the old gallery and go across to a fresh install.

    • patheticcockroach says

      Interesting feedback, thanks.
      I guess I’m a small Piwigo user, as I had like 350-400 pictures when I did the migration, but I don’t really see how having too many galleries can make the migration fail. Except if maybe you hit some kind of timeout? (if you ran the script in your browser rather than in the console)



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA