[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Openexr-devel] Modifying an attribute
From: |
Florian Kainz |
Subject: |
Re: [Openexr-devel] Modifying an attribute |
Date: |
Mon, 03 May 2004 11:04:05 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030314 |
Brad Hards wrote:
Is there a standard (safe) way to modify the attribute in a file on the disk?
Is it going to be a matter of reading the whole file, modifying the attribute
and writing the whole thing back out?
Brad
_______________________________________________
Openexr-devel mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/openexr-devel
Hi Brad,
because modifying an attribute can change its size, there
is currently no way to modify an attribute in place, without
rewriting the file.
However, the IlmImf library does support a copyPixels()
function that copies from one file to another without
uncompressing and re-compressing the pixels. Using this
function, changing an attribute is takes about as long as
as simply copying the file.
The code snippet below (adapted from the exrstdattr utility)
inserts a string attribute into a file's header. If an
attribute with the same name exists already, it is replaced.
Florian
---
InputFile in (inFileName);
Header header = in.header();
header.insert ("foo", StringAttribute ("bar");
if (header.hasTileDescription())
{
TiledOutputFile out (outFileName, header);
out.copyPixels (in);
}
else
{
OutputFile out (outFileName, header);
out.copyPixels (in);
}