Ejemplo n.º 1
0
        /// <summary>
        /// Remvoes EXIF properties from an image.
        /// </summary>
        /// <param name="inputPath">file path of original image</param>
        /// <param name="outputPath">file path of modified image</param>
        /// <param name="exifTags">tags to remove</param>
        public static void RemoveExifData(string inputPath, string outputPath, IEnumerable <ExifTag> exifTags)
        {
            // minimally load image
            Image image;

            using (ExifReader.LoadImage(inputPath, out image))
            {
                using (image)
                {
                    ExifWriter.RemoveExifData(image, exifTags);
                    image.Save(outputPath);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds an EXIF property to an image.
        /// </summary>
        /// <param name="image"></param>
        /// <param name="property"></param>
        public static void AddExifData(Image image, ExifProperty property)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }
            if (property == null)
            {
                return;
            }

            PropertyItem propertyItem;

            // The .NET interface for GDI+ does not allow instantiation of the
            // PropertyItem class. Therefore one must be stolen off the Image
            // and repurposed.  GDI+ uses PropertyItem by value so there is no
            // side effect when changing the values and reassigning to the image.
            if (image.PropertyItems == null || image.PropertyItems.Length < 1)
            {
                propertyItem = ExifWriter.CreatePropertyItem();
            }
            else
            {
                propertyItem = image.PropertyItems[0];
            }

            propertyItem.Id   = (int)property.Tag;
            propertyItem.Type = (short)property.Type;

            Type dataType = ExifDataTypeAttribute.GetDataType(property.Tag);

            propertyItem.Value = ExifEncoder.ConvertData(dataType, property.Type, property.Value);
            propertyItem.Len   = propertyItem.Value.Length;

            // This appears to not be necessary
            ExifWriter.RemoveExifData(image, property.Tag);
            image.SetPropertyItem(propertyItem);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Remvoes EXIF properties from an image.
 /// </summary>
 /// <param name="image"></param>
 /// <param name="exifTags">tags to remove</param>
 public static void RemoveExifData(Image image, params ExifTag[] exifTags)
 {
     ExifWriter.RemoveExifData(image, (IEnumerable <ExifTag>)exifTags);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Remvoes EXIF properties from an image.
 /// </summary>
 /// <param name="inputPath">file path of original image</param>
 /// <param name="outputPath">file path of modified image</param>
 /// <param name="exifTags">tags to remove</param>
 public static void RemoveExifData(string inputPath, string outputPath, params ExifTag[] exifTags)
 {
     ExifWriter.RemoveExifData(inputPath, outputPath, (IEnumerable <ExifTag>)exifTags);
 }