Welcome Guest! You need to login or register to make posts.



Go to last post Go to first unread
#1 Posted : Friday, July 20, 2018 3:16:53 PM(UTC)

Rank: Member

Groups: Member
Joined: 7/30/2017(UTC)
Posts: 18

Thanks: 7 times
When I try to follow the sample code on line for writing XMP data the original image seems to be removed from the disk and no new image is written. The following message is written to the console window my application is running in, “ImageWriter cannot produce stripes, just return.”. Here is the sample code I wrote:

private static void AddMediaIdToImage(string imagePath, string mediaId)
            XmpData xmp = null;
            string dir = Path.GetDirectoryName(imagePath);
            string file = Path.GetFileNameWithoutExtension(imagePath);
            file += "(2).jpg";
            file = Path.Combine(dir, file);

            using (var jpegReader = new JpegReader(imagePath))
            using (var jpegWriter = new JpegWriter(file))
                xmp = new XmpData();

                //Check if XMP data are present in the file and...
                if (jpegReader.Xmp != null)
                    //...get an XML code from the reader
                    xmp = new XmpData(jpegReader.Xmp);
                    //...or create an empty structure
                    xmp = new XmpData();

                var ns = XmpNamespace.AddNamespace("http://photoboothsupplyco.com/", "pbsco:");
                var node = new XmpValueNode(XmpNodeType.SimpleProperty, mediaId, ns, "pbsco:mediaId");

                jpegWriter.Xmp = xmp.Save();

Is it possible to edit the XMP data in a file without writing a new file? I want to make sure I preserver any other metadata stored in the file.
#2 Posted : Wednesday, July 25, 2018 11:27:47 PM(UTC)

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,656

Thanks: 5 times
Was thanked: 75 time(s) in 73 post(s)
Hi Lauren,

Unfortunately, you still need to read and write back metadata. However, you can avoid JPEG recompressing using the special classes for lossless JPEG processing.
Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.