Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to extract 'copyright status' from JPEG in C#

I created an app which reads the JPEG meta data and stores it in the database, so that we can see if it has rogue characters. I can extract the meta data using below code but i am unable to extract copyright Status. Is there a way i can extract that?

var stream = new FileStream(file, FileMode.Open, FileAccess.Read);
                        var decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
                        var metadata = decoder.Frames[0].Metadata as BitmapMetadata;
                        if (metadata != null)
                        {
                            dataGridView1.Rows.Add(file,
                                metadata.ApplicationName,
                                metadata.Author != null ? metadata.Author.Aggregate((old, val) => old ?? "" + "; " + val) : "",
                                metadata.CameraManufacturer,
                                metadata.CameraModel,
                                metadata.Comment,
                                metadata.Copyright,
                                metadata.DateTaken,
                                metadata.Format,
                                metadata.Keywords != null ? metadata.Keywords.Aggregate((old, val) => old ?? "" + "; " + val) : "",
                                metadata.Location,
                                metadata.Rating,
                                metadata.Subject,
                                metadata.Title,
                                metadata.GetQuery("/xmp/photoshop:Instructions"),
                                metadata.GetQuery("/xmp/xmpRights:UsageTerms/x-default"),
                                metadata.GetQuery("/xmp/photoshop:Credit")
                                );
                        }

Is it possible to get "Copyright status" from code? this is in Photoshop and we can view it in Photoshop.

Copyright status

like image 273
Kamran Pervaiz Avatar asked Nov 22 '25 19:11

Kamran Pervaiz


1 Answers

There is no copyright field defined by JPEG. The Exif file format supports a copyright. Maybe others as well.

If you want the copyright information, you would have to determine if you have an Exif file. If so, you would have to look for an APP1 marker after the SOI marker, determine if it is an EXIF header, then search through the TIFF header embedded in the marker and look for a copyright tag.

like image 109
user3344003 Avatar answered Nov 25 '25 07:11

user3344003