This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
lauren@photoboothsupplyco.com  
#1 Posted : Friday, July 20, 2018 3:16:53 PM(UTC)
lauren@photoboothsupplyco.com

Rank: Member

Groups: Guest
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:

Code:
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);
                }
                else
                {
                    //...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");
                xmp.AddNode(node);

                jpegWriter.Xmp = xmp.Save();
                Pipeline.Run(jpegReader+jpegWriter);
            }
 }

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.

Fedor  
#2 Posted : Wednesday, July 25, 2018 11:27:47 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Guest
Joined: 7/28/2003(UTC)
Posts: 1,660

Thanks: 5 times
Was thanked: 76 time(s) in 74 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
Guest (2)
Similar Topics
PDF XMP Metadata (Discussions – Graphics Mill)
by Franchi_S5 6/22/2023 6:01:03 AM(UTC)
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.