Writes tags to a file or changes existing tags in a file.
#include "l_bitmap.h"
L_LTFIL_API L_INT L_WriteFileTag(pszFile, pSaveOptions)
Character string that contains the filename.
Pointer to optional extended save options. Pass NULL to use the default save options. pSaveOptions.PageNumber indicates the page on which to write the tags. Note that an error code will be returned if the page does not exist.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function writes tags into an existing file or changes tags in an existing file.
This function will write all the tags that have been set using L_SetTag. There must be at least one tag set for this function to work. If no tags have been set, an error will be returned by this function.
This function works only with EXIF, TIFF, and PNG files.
Some restrictions apply to this function if you use an IFD to indicate to which page to write the tags. See the Loading and Saving Large TIFF/BigTIFF Files topic for more information.
Note: Use this function carefully. LEADTOOLS will not restrict the tags that you write. If you write bad tags, the file might become corrupted. Consult the TIFF documentation for a list of predefined tags. It is recommended that you write only the user-defined tags (the tags between 0x8000 and 0xFFFF).
See the TIFF documentation for a complete list of the TIFF tags and types.
When you add or remove comments or tags, the comments and tags array at the end of the TIFF/Exif image file is re-written. When you modify existing comments or tags, the new value is added to the file and the IFD is modified as necessary. In all of these cases, there is no image recompression.
Win32, x64, Linux.
L_INT WriteFileTagExample()
{
L_INT nRet;
L_UINT16 LogoPosition = 0x8001; /* my private tag */
L_UINT16 TagType = TAG_SHORT; /* tagged data type */
L_UINT32 TagCount = 4; /* count of data items */
L_INT16 TagData[] = {5, 5, 24, 37};
L_VOID* pTagData = &TagData; /* pointer to the buffer containing the data */
SAVEFILEOPTION SaveFileOption;
/* Set the tag data to be saved */
nRet = L_SetTag(LogoPosition, TagType, TagCount, pTagData);
if(nRet < SUCCESS)
return nRet;
nRet = L_GetDefaultSaveFileOption(&SaveFileOption, sizeof(SAVEFILEOPTION));
if(nRet != SUCCESS)
return nRet;
SaveFileOption.PageNumber = 1;
/* Save the file with the tag. Note that TEST.TIF must exist and contain at least one page! */
nRet = L_WriteFileTag(MAKE_IMAGE_PATH("TEST.TIF"), &SaveFileOption);
if(nRet != SUCCESS)
return nRet;
/* Clear the tag from memory */
nRet = L_SetTag(0, 0, 0, NULL);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document