help needed - code for retrieving original image path

dmdwiggi

Joined: 2008-10-16
Posts: 1
Posted: Thu, 2008-10-16 17:37

Hello,

I used the symlink option to import a large number of images. For reasons I'll explain at the bottom*, I need to be able to retrieve the path of the original image and store it in a custom field.

Obviously I know how to resolve a symlink once I know where the link lives. But I have been unable to figure out how to write a script that resolves a given Gallery Item ID into a true filesystem path for the original image.

So, in short, what I need is a PHP function that, given a Gallery ID number, will return a path like

/home/hne/gallery/g2data/albums/archives/stebbins/steb00068f.jpg

I could then use PHP's readlink() function to get the original item location.

I've done a fair amount of PHP development, but have never worked with the Gallery API before, and frankly am finding it quite daunting. I've also poked around in the MySQL database, but can't see where this information is easily accessible. I have spent a lot of time staring at the forums, API documentation, etc.

I don't really need this to be elegant -- I just need to use it once to apply the original item source metadata to each image. A simple utility script would actually be ideal -- doesn't need to be a full-fledged gallery module.

Can anyone help me out with some sample code that would get me going in the right direction on this?

Thanks in advance,

David Dwiggins

* For anyone curious, my issue is that I did not load the highest resolution version of the images into Gallery due to server disk space issues. So the "master" image that Gallery knows about is really only a derivative of a much larger TIFF file. Knowing the filesystem path of the JPEG I symlinked into Gallery is necessary to retrieve the original TIFF. I need to provide this information as part of the metadata in Gallery2.