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?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-04-03 17:02

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)

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Sun, 2005-04-03 17:43

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

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-04-03 18:23

(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.

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Sun, 2005-04-03 18:52

Thanks I know how to get the metadata.

One more question, what program do you use when you write PHP?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-03 20:29

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.

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 06:16

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.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-04 06:46

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

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 06:49

thanks now I'm getting somewhere.

One more:
How do I get a hold of the file? is the path saved in some method?

 
virshu
virshu's picture

Joined: 2003-09-13
Posts: 314
Posted: Mon, 2005-04-04 07:03

$item->getPathComponent()

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 09:24

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.

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 12:04

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.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-04-04 13:54

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.

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 14:49

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.

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 15:05

I found the error, my bad.

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 15:17

Me again.
$item->getPathComponent() only returns the filename, I have to hav the whole path how do I get it?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-04 16:19

fetchPath

 
lindehoff

Joined: 2005-04-03
Posts: 20
Posted: Mon, 2005-04-04 16:38

Do you meen:
$item->fetchPath()

Thats and array

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-04 19:34

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 .....