←Select platform

DeleteComment(string,int,RasterCommentMetadataType) Method

Summary
Deletes a comment field from a file.
Syntax
C#
C++/CLI
Python
public void DeleteComment( 
   string fileName, 
   int pageNumber, 
   RasterCommentMetadataType type 
) 
public: 
void DeleteComment(  
   String^ fileName, 
   int pageNumber, 
   RasterCommentMetadataType type 
)  
def DeleteComment(self,fileName,pageNumber,type): 

Parameters

fileName
A String containing the input file name.

pageNumber
1-based index of the page from which to read the comment.

type
The type of comment. Refer to Types of File Comments.

Remarks

This function only applies to TIF, EXIF, JPEG, JPEG 2000, and PNG files.

You can use CommentsSupported to determine whether a certain file format supports comments.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
 
public void DeleteCommentExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"); 
 
   RasterCommentMetadataType commentType = RasterCommentMetadataType.IptcKeywords; 
   RasterCommentMetadata comment = codecs.ReadComment(srcFileName, 1, commentType); 
   if (comment == null) 
      Debug.WriteLine("comment is missing!"); 
   else 
   { 
      codecs.DeleteComment(srcFileName, 1, commentType); 
 
      comment = codecs.ReadComment(srcFileName, 1, commentType); 
      if (comment != null) 
         Debug.WriteLine("comment is still there!"); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.*; 
import java.net.*; 
import java.nio.file.Paths; 
import java.util.*; 
import java.time.Instant; 
import java.time.Duration; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.codecs.RasterCodecs.FeedCallbackThunk; 
import leadtools.drawing.internal.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.color.ChangeIntensityCommand; 
import leadtools.svg.*; 
 
 
public void deleteCommentExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
 
   String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "cannon.jpg"); 
 
   RasterCommentMetadataType commentType = RasterCommentMetadataType.IPTC_KEYWORDS; 
   RasterCommentMetadata comment = codecs.readComment(srcFileName, 1, 
         commentType); 
   codecs.deleteComment(srcFileName, 1, commentType); 
 
   comment = codecs.readComment(srcFileName, 1, commentType); 
   assertTrue("Comment was not deleted as expected", comment == null); 
 
   // Clean up 
   codecs.dispose(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.