Simplest way to get a file:// url image into an existing gallery without duplicating data?

d-rock

Joined: 2009-03-18
Posts: 5
Posted: Mon, 2009-06-01 16:08

I've been poking around Gallery innards trying to figure this out, gave up, tried to just hack the database directly and now I'm coming back to the forum with my hat in hand asking for some help. I have a catalog file containing file:// urls for a set of images (on the order of 100-200 images per catalog file). I would like to be able to import this file, and I want to use symlinks in order to not duplicate many GB of image data on my hard drive. Currently to use symlinks I have to use the Gallery web interface and hand-select all of the images which is very tedious and error prone. Can anyone point me in a direction to figure out how to programmatically add symlink images to a gallery?

Thanks,

Derek

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2009-06-01 20:35

See here:
http://gallery.menalto.com/node/81010#comment-284733

I've not tested or examined it, and you'll have to do some work to get it to work with symlinks (I don't even know how they're handled within gallery, you'll have to examine the core code to find out)

 
d-rock

Joined: 2009-03-18
Posts: 5
Posted: Wed, 2009-06-03 19:58

Solved. I finally figured out what I was missing: the docs don't clearly specify that the return from most API calls is an array of [GalleryStatus,Result], so I could never figure out what was going on. Once I got past that hurdle I hammered the attached script together and it works great. Whatever user you run this as has to have write access to the g2data tree. I would call this early alpha software but I've tested it and it works great. The script can take a gThumb collection file (corresponds to a gThumb catalog, found under the ~/.gnome2/gthumb/collections/ folder) and an albumId (can be determined by running the script with just a "-a" flag) and will import all of the gThumb collection files into the specified album using symlinks.

Thanks!

Derek

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-06-03 20:23
Quote:
the docs don't clearly specify that the return from most API calls is an array of [GalleryStatus,Result]

Well, they sort of do: all of the return values are automatically documented in the API docs: http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html - although if you don't read it right I guess it's not obvious. But a quick look at some example code from the Gallery core makes it fairly clear.

Good that you got it working.

 
d-rock

Joined: 2009-03-18
Posts: 5
Posted: Wed, 2009-06-03 20:40

Sorry, I meant that the docs look like:

Quote:
Return: GalleryStatus a status code array (albumId => array(albumId => array, ..), ..)

And I was reading that as

Quote:
GalleryStatus: a status code array (that looks like (albumId => array(albumId => array, ..), ..)

instead of

GalleryStatus: a status code
array: (...)

It looks like a minor punctuation issue, but the meaning changes a lot :)
Derek