none
Editing Exif Jpeg data.

    Question

  • Hi

    Trying to edit the tags and title of over 2000 images in bulk. But I'm having a problem; I don't know how. I've looked online on how to do it and all the classes I'd expect to be there a not. For example. I can't do 'Image.FromFile(File)' because it isn't there. I haven't a clue as to what can do to allow me to bulk edit this batch of images automatically. Am I missing something blatantly obvious?

    Thanks,

    Duke.

    Thursday, April 20, 2017 7:21 PM

All replies

  • Hello,

     Not all JPG/JPEG files will have an EXIF header.  But for files that do you need to

    read about this information from the following link;

     

      Topic Links:

      https://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat(v=vs.110).aspx

      https://social.msdn.microsoft.com/Forums/en-US/5717c15c-1e16-44f0-bb23-ca9ab7ef3cfe/how-to-modify-exif-of-digital-photo-by-c?forum=csharplanguage 

     

      Please take the time to read the articles. 

     Hope this helps :)


    • Edited by User3DX Friday, April 21, 2017 1:34 AM Links Added
    Friday, April 21, 2017 1:27 AM
  • Like User3DX clarified, JPEG images might be EXIF files, but they could also be JFIF with no Exif header.
    If you still haven't solved this, consider using the LEADTOOLS imaging toolkit (https://www.leadtools.com/sdk/formats/metadata) which you can use to process your JPEG images, examine whether they're Exif and write EXIF comments to them. (Disclaimer: I am an employee of the vendor of this toolkit).

    The toolkit supports reading and writing the EXIF comments mentioned here:
    https://www.leadtools.com/help/leadtools/v19/dh/to/l-topics-exiffilecomments.html

    The code to do this would look like something like this:

    string[] imageList = Directory.GetFiles(@"Path to Images Folder");
    foreach (string imageFileName in imageList)
    {
        using (RasterCodecs codecs = new RasterCodecs())
        {
            RasterImageFormat format;
            using (CodecsImageInfo info = codecs.GetInformation(imageFileName, false))
            {
                format = info.Format;
            }
            if (RasterCodecs.CommentsSupported(format))
            // to check for Exif, change previous line to become:
            // if (format == RasterImageFormat.ExifJpeg || format == RasterImageFormat.ExifJpeg411)
            {
                RasterCommentMetadata comment = new RasterCommentMetadata();
                comment.Type = RasterCommentMetadataType.Title;
                comment.FromAscii("New Title");
                codecs.WriteComment(imageFileName, 1, comment);
            }
        }
    }
    



    • Edited by Hussam_B Thursday, December 7, 2017 5:22 PM
    Thursday, December 7, 2017 5:19 PM