Member
Member
Anudu   08-03-2008, 14:41
#1

First of all: thankyou for zenphoto! It's quick, it's uncomplicated and it does it's job! Don't add too much extras and I luv you forever.

I had gallery2 running and it was a pain. Much too huge and hard to understand, when you needed to tweak it.

I wrote this perl script to import the image description from within gallery. Use at your own risk and only, if you know what you're doing:

---snip---

!/usr/bin/perl


##############################################################################
use DBI();
$user = "xxx";
$password = "xxx";
$dbh = DBI->connect("DBI:mysql:database=xxx;host=localhost", "$user", "$password",
{'RaiseError' => 1});
$counter = 0;
%UMLAUTE = ( 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue','ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss');
@UMLKEYS = join("|", keys(%UMLAUTE));

$cursor = $dbh->prepare("select gallery2_FileSystemEntity.g_id, gallery2_FileSystemEntity.g_pathComponent, gallery2_Item.g_description from
gallery2_FileSystemEntity, gallery2_Item where gallery2_FileSystemEntity.g_id = gallery2_Item.g_id;") || die "Prepare schiefgegangen ($DBI::errstr)";

$cursor->execute() || die "Query schiefgegangen ($DBI::errstr)";
while(defined(my $row = $cursor->fetch))
{
$id = $row->[0];
$datei = $row->[1];
$besch = $row->[2];

$besch =~ s/(@UMLKEYS)/$UMLAUTE{$1}/g;
$besch = $dbh->quote($besch);
$datei = $dbh->quote($datei);

my $statement = "UPDATE zen_images SET title = $besch WHERE filename = $datei";

$dbh->do("$statement");

$counter++;
print "$counter: $datei --- $besch\n";

select(undef, undef, undef, 0.2); ## wait 200 ms for the database
}}
}
exit(0);
---snap---

It's intended to run in the shell, so don't try to call it from a browser. And check, if the queries work with your database, before you try.

Might help someone get rid of Gallery2!

Administrator
Administrator
acrylian   08-03-2008, 15:56
#2

I will add a link to this thread on our extensions page.

Member
Member
Megan   10-08-2008, 15:47
#3

Just a few tips if you're using this:

  • make sure to check the prefixes on the Gallery and Zenphoto tables. Mine are g2 and zp, not gallery2 and zen

This script assumes that you're putting zenphoto in the same database as Gallery. If yours is in a different database, simply define a second database conection and send the update statement to the new database:

`

$dbh2 = DBI->connect("DBI:mysql:database=xxxx;host=localhost", "$user", "$password",{'RaiseError' => 1});

my $statement = "UPDATE zp_images SET title = $besch WHERE filename = $datei";

$dbh2->do("$statement");

`

My databases both use the same usernames and passwords. if yours are different you'd need to define new variables for those as well.

Member
Member
efurban   10-08-2008, 17:22
#4

inspired by this tool, I have wrote the migrator for gallery2 to zenphoto. http://apps.ouwu.com/confluence/display/pb/Gallery2+to+ZenPhoto+Migrator

Member
Member
Megan   17-08-2008, 01:35
#5

That migrator didn't work for me - the image descriptions didn't copy over.

After running it I realized that the perl script above didn't work either. My husband ended up writing a sql statement that works:

`

UPDATE zendatabase.zp_images im

INNER JOIN gallerydatabase.g2_FileSystemEntity fse ON im.filename=fse.g_pathComponent

INNER JOIN gallerydatabase.g2_Item item ON fse.g_id=item.g_id

INNER JOIN gallerydatabase.g2_ChildEntity ce ON item.g_id=ce.g_id

INNER JOIN zendatabase.`zp_albums zp_albums ON im.albumid=zp_albums.id
INNER JOIN (SELECT g_id, REPLACE(REPLACE(g_title, '"', '"'), '&', '&') galltit FROM gallerydatabase.g2_Item WHERE g_canContainChildren=1) AS g_album ON ce.g_parentId=g_album.g_id
SET im.desc = item.g_summary
WHERE g_album.galltit=zp_albums.title

Replace the gallerydatabase and zendatabase with the correct database names. ALso check the table prefixes and change them to match yours.

Member
Member
efurban   19-08-2008, 19:07
#6

Megan, could you please send me the log file or output of the Migrator? The tool worked for me so I wanna find out why it didn't work for you. hopefully this eventually will become a useful tool for everyone else.

Member
Member
krainbolt   19-08-2008, 23:07
#7

efurban, on your site under "Features" you state:

"migrate photos: titles only (since I don't have descriptions for photos in Gallery2)"

Wouldn't this likely be the reason image descriptions aren't converting over?

Junior Member
Junior Member
dbogen   08-05-2012, 03:01
#8

Went through this process recently. After Googling around for a solution, I mashed together several partial solutions and came up with a Frankenstein script that does most of the heavy lifting for you. The script is posted on my website at http://www.bogen.org/2012/05/07/gallery2-to-zenphoto-migration/

Administrator
Administrator
acrylian   08-05-2012, 09:15
#9

Ok, we will put an entry for this on the extensions section, too.

Administrator
Administrator
acrylian   08-05-2012, 09:27
#10

Great, I have put an entry on our extensions section:
http://www.zenphoto.org/news/gallery2-to-zenphoto-migration

If we may ask why did you choose Zenphoto against for example the newer Gallery3?

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.