Save a TIFF with modified tags

I would like to load a TIFF image, do some analysis, then save the image under a new name with modified tags based on my analysis.
I can load the tiff and appropriate tag data with ImageLoad.
How might I go about saving the tiff with modified tags? It seems SavePict is inappropriate, should I be writing a new binary file?
741 wrote:
Take a look at the ImageSave operation with the /WT flag.


Thanks, ImageSave is what I need.
I am still having some problems though, let me walk through what I am trying:

I load the tiff tag info: ImageLoad/Q/O/T=tiff/RTIO
This creates a folder called Tag0, in which there are several waves, T_Tags is the main one.
I then load the image and do some analysis.

I duplicate the folder Tag0: DuplicateDataFolder  root:Tag0,  root:Tagwrite
I make some changes in the appropriate tag waves (which are referred to from T_Tags).
I attempt to save: ImageSave/D=8/O/T="tiff"/WT = root:Tagwrite:T_Tags  root:result

After specifying the save path I get the error: ImageSave error. " A Tag wave can't overwrite a primary tag."
The image is saved successfully, with most of the tags, but does not include any of the "unknown" tag values - the ones I am modifying.
The "unknown" tags are loaded just fine but it seems I cannot write them.
According to the ImageSave help:
"You must make sure that: (1) tag numbers are legal and do not conflict with any existing tags; (2) the data type and data size are consistent with the amount of data saved in external waves."
Does this mean that I am not allowed to write "unknown" tag values?
If so, is there any other way around this?
While I have not looked at this in detail, I think you're seeing this error because your tag wave is setting some properties that ImageSave thinks it should be in control of.

For example, it doesn't make sense to set the BITSPERSAMPLE tag using a tag wave since only one value is correct, and ImageSave takes care of that one. I think you will just have to delete these tags from the tag wave.

I'm not sure if there's anything wrong with moving the waves to another data folder. Perhaps it's fine - I just haven't looked at it.
You were right.
I got rid of the stuff that ImageSave thought it should be in control of and only used the tags I was modifying.
It now saves without any errors.
I re-loaded the tags from the saved image and everything looks good.
Thanks 741!