Dear all,
I'm trying to assign an ICC profile to an image / an exiftool object by
$et->SetNewGroups('ICC_Profile');
$et->SetNewValue('ICC_Profile' => $icc);
where $icc is a blob or a file. Both throws an error like "Tag 'ICC_Profile' is unsafe for writing".
I whould like to avoid assigning the profile by Image::Magick (which works).
Added recent: Adding Protected => 1 doesn't help; throws error "Error opening file" wether $icc is a file, filehandle or blob.
You don't need to call SetNewGroups().
The SetNewValue() call expects the ICC profile data. If you have a file name, read it into a buffer (ie. $buff), and pass $buff to SetNewValue(). Alternatively, call $et->SetNewValuesFromFile($file, 'ICC_Profile');
You do need to set Protected => 1 for this as you discovered.
- Phil
Thank you Phil.
Yes, I tried to read the profile file to a scalar buffer with
open ICCFH, '<', $iccFile};
undef $/;
$icc = <ICCFH>; # get blob
close ICCFH;
$/ = "\n";
and used it with IMagick - and it worked: $newimg->Profile(name => 'ICC', profile => $icc);
But with ExifTool: SetNewValue( $icc ) fails of course (new value for what?),
also SetNewValue( $icc, 'ICC_Profile' ) fails (Tags ???? - $icc is no Tag)
also SetNewValue( 'ICC_Profile', $icc ) fails (my first attempt and the way other things are working).
- Ludwig
Hi Ludwig,
You seem to be trying things randomly. If $icc contains the profile data, then the call is:
$et->SetNewValue('ICC_Profile', $icc, Protected => 1);
And to be clear, after this you must of course call
$et->WriteInfo($outfile);
- Phil
Hi Phil,
as I reported / added in my first post, I first tried it exact as you say:
$et->SetNewValue('ICC_Profile' => $icc, Protected => 1);
and I got:
Writing ICC_Profile:ICC_Profile if tag exists (from: $et->Options(Verbose => 3); ) and then
Error = Error opening file (from STDERR)
I also tried to use a file handle or path to the file.
- Ludwig
Hi Ludwig,
I'm sorry, but I don't understand.
Quote from: humbleweed on November 20, 2013, 10:24:43 AM
as I reported / added in my first post, I first tried it exact as you say:
$et->SetNewValue('ICC_Profile' => $icc, Protected => 1);
and I got:
Writing ICC_Profile:ICC_Profile if tag exists (from: $et->Options(Verbose => 3); ) and then
Error = Error opening file (from STDERR)
What file was it trying to open? That command should not open a file if $icc contains the profile data in memory.
- Phil