Photoshop metadata
lindehoff
Joined: 2005-04-03
Posts: 20 |
Posted: Sun, 2005-04-03 07:05 |
I have used Photoshop to add keyword, title and description to all my pictures. Is there a way to get that data to G2? |
|
Posts: 8601
we can guide you in writing the code to do this, if you're up to it..
you would add your own module with an ItemAddOption.. this basically runs your piece of code after each item is added to G2.. your code can examine the file and see if it has this photoshop metadata and set the appropriate values in G2 if found.
a good example of similar code is in the exif module (set description from exif description)
Posts: 20
OK, I have some experience with PHP but I usally write C#.
Where should I start? How do I write the module? Do you have a class libary?
//Jacob
Posts: 8601
(note-- before you follow all these steps, make sure you have some way to read the photoshop metadata... we can help you get all the G2 stuff done, but if you can't read the data from the file then it won't matter!)
excellent.. here are some first steps:
1) create a new directory under modules
2) copy modules/uploadapplet/module.inc into your new module directory
3) edit your module.inc.. setId must match your directory name, set the class name, give it a name and description, change the group if you like (see other module.inc's).
4) update the registerFactoryImplementation call.. look at the 3rd such call in modules/exif/module.inc, for ExifDescriptionOption.. you'll want a similar call; ie, first param is 'ItemAddOption', the others are for a new Option class you'll add in your module.
5) copy modules/exif/ExifDescriptionOption.class to your module directory and give it an appropriate name.. update isAppropriate to just return true, then implement the handleRequestAfterAdd function.. look at how this exif class works to see how to save changes to the G2 items. you'll need to figure out how to read the photoshop meta data though.
Posts: 20
Thanks I know how to get the metadata.
One more question, what program do you use when you write PHP?
Posts: 32509
most of us don't use an IDE for php. emacs or your prefered editor + php-mode are fine. the are php IDEs though. eclipse is problematic, because of the .class files.
Posts: 20
I have a question, in ExifDescriptionOption.inc thay use:
$item->setSummary()
is there away to find out all $item's methods??
I can't find it in the documentation.
Posts: 8601
that one is part of modules/core/classes/GalleryItem.class (though that method is actually defined in modules/core/classes/interfaces/GalleryItem.inc)
the main fields you'll be dealing with, which you'll be familiar with from using the app, are setTitle, setSummary, setDescription, setKeywords
Posts: 20
thanks now I'm getting somewhere.
One more:
How do I get a hold of the file? is the path saved in some method?
Posts: 314
$item->getPathComponent()
Posts: 20
Great.
I'm ready to try it now but have some truble:
I install it and the system say that it went OK, but when I look at it it´s just a litle hammer where the green thumb sould be and on the right it's a upgrade link.
It dosen't seem to do any thing.
Posts: 20
It seems to work to install now I don't get the upgrade option annyway. But I'm not sure the module is running. It dosen't do anything, is there a way to test if the module is running when it should, in my case when I add a picrute.
Posts: 32509
test? echo debug info, (enable G2 debug mode and use it), "or" create unit tests, or if it already fully functional, just add an image and check if the data is extracted.
Posts: 20
I tried to add some code that should write some text in a text file when a file was uploaded but nothing was written.
Can someone check my code and see if I'm on the right track.
Posts: 20
I found the error, my bad.
Posts: 20
Me again.
$item->getPathComponent() only returns the filename, I have to hav the whole path how do I get it?
Posts: 8601
fetchPath
Posts: 20
Do you meen:
$item->fetchPath()
Thats and array
Posts: 8601
look through the code a bit.. there's lots of examples of how these methods are used.
list ($ret, $path) = $item->fetchPath();
if ($ret->isError()) {
return .....