Unable to write to PSD Files

Started by nranjith, January 25, 2011, 11:34:52 AM

Previous topic - Next topic

nranjith

Hi,

I am trying to write meta data using the below perl script to a .psd I am not able to write to it, could you please help ?

#!/usr/bin/env perl
use Image::ExifTool;

my $exifTool = new Image::ExifTool;

# Extract arguments
if (@ARGV != 2) {
   exit -1;
}


my $filePath = $ARGV[0];
my $fileId = $ARGV[1];

# NEW XMP TAGS
%Image::ExifTool::UserDefined::blah = (
   GROUPS => { 0 => 'XMP', 1 => 'XMP-blah', 2 => 'Image' },
   NAMESPACE => { 'fda' => 'http://namespace.blach.net.uk/xml/asset/1.0/' },
   WRITABLE => 'string',
   FileId => { },
);

# NEW XMP NAMESPACES MUST BE ADDED TO THE MAIN XMP TABLE
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::XMP::Main' => {
       fda => {
          SubDirectory => {
             TagTable => 'Image::ExifTool::UserDefined::blah',
            },
         },
      },
   );
$exifTool->SetNewValue('FileId',$fileId);
$exifTool->WriteInfo($filePath);

Regards

Phil Harvey

Hmmm.  Works fine for me.  I added $exifTool->Options(Verbose => 3) to your script just before the call to WriteInfo, and I get this output:


> ./test_script a.psd test
Name "Image::ExifTool::UserDefined::blah" used only once: possible typo at ./test_script line 22.
Writing XMP-blah:FileId
Rewriting a.psd...
  FileType = PSD
  MIMEType = application/vnd.adobe.photoshop
  Editing tags in: Photoshop XMP
  Creating tags in: Photoshop XMP
  Rewriting IPTC
    [nothing changed]
  Rewriting XMP
    + XMP-blah:FileId = 'test'
  Rewriting Photoshop
  Rewriting ICC_Profile

> exiftool a.psd -fileid -G1
[XMP-fda]       File Id                         : test


(BTW, you can avoid the warning by using the variable again in some dummy context.)

What version of ExifTool are you using?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

nranjith

Thanks Phil,

I tried with the  $exifTool->Options(Verbose => 3) and found the error "Format error in file".  I shall check whats wrong with file.

Regards

Quote from: Phil Harvey on January 25, 2011, 11:56:44 AM
Hmmm.  Works fine for me.  I added $exifTool->Options(Verbose => 3) to your script just before the call to WriteInfo, and I get this output:


> ./test_script a.psd test
Name "Image::ExifTool::UserDefined::blah" used only once: possible typo at ./test_script line 22.
Writing XMP-blah:FileId
Rewriting a.psd...
  FileType = PSD
  MIMEType = application/vnd.adobe.photoshop
  Editing tags in: Photoshop XMP
  Creating tags in: Photoshop XMP
  Rewriting IPTC
    [nothing changed]
  Rewriting XMP
    + XMP-blah:FileId = 'test'
  Rewriting Photoshop
  Rewriting ICC_Profile

> exiftool a.psd -fileid -G1
[XMP-fda]       File Id                         : test


(BTW, you can avoid the warning by using the variable again in some dummy context.)

What version of ExifTool are you using?

- Phil