Meet us at PRINT 19. Chicago, IL. Oct. 3 - 5.
Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Raymund  
#1 Posted : Monday, July 1, 2019 1:44:17 PM(UTC)
Raymund

Rank: Newbie

Groups: Member
Joined: 10/2/2015(UTC)
Posts: 2

Hi,

This question may similar to another topic "Problems when saving Exif and IPTC" in the forum, but even if I try to remove the thumbnail, I still get the following error:

EXIF data object is too big, its size exceeds 64K limit (that is defined by Jpeg standart for APP1 marker data)

Can you please provide more information about this?

BTW, Aurigma.GraphicsMill version is 7.5.82.0 and the image link is below:
Failed Image

Code:

	public class Program
    {
        public static void Main(string[] args)
        {
            var sourceImageData = File.ReadAllBytes("where_the_file_is");
				
			using (MemoryStream ms = new MemoryStream(sourceImageData))
			{
				var metadatas = GetMetadata(ms);
				var orgExif = metadatas.Item1;
				var orgIptc = metadatas.Item2;
				ms.Position = 0;

				using (var rgbSourceStream = new MemoryStream())
				{
					using (var rawBitmap = new Aurigma.GraphicsMill.Bitmap(ms))
					{
						rawBitmap.ColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb();
						if (rawBitmap.PixelFormat.IsCmyk || rawBitmap.PixelFormat.IsGrayscale)
						{
							rawBitmap.ColorManagement.Convert(Aurigma.GraphicsMill.ColorSpace.Rgb, true, rawBitmap.PixelFormat.IsExtended);
						}

						// save metadata back
						JpegSettings encdr = new JpegSettings
						{
							Quality = 100,
							IsProgressive = false
						};
						
						// update author and copyright, but not applicable for this case, you can ignore the commented code
						//if (!is3rdParty)
						//{
						//	orgExif[Aurigma.GraphicsMill.Codecs.ExifDictionary.Artist] = _author;
						//	orgExif[Aurigma.GraphicsMill.Codecs.ExifDictionary.Copyright] = string.Format(_copyRightFormat, DateTime.Now.Year);
						//}
						
						encdr.Exif = orgExif;
						encdr.Iptc = orgIptc;

						try
						{
							rawBitmap.Save(rgbSourceStream, encdr);
						}
						catch (JpegMarkerException ex)
						{
							if (ex.Message.IndexOf("64K limit") != -1
								&& encdr.Exif != null && encdr.Exif[ExifDictionary.Thumbnail] != null)
							{
								encdr.Exif.Remove(ExifDictionary.Thumbnail);

								rawBitmap.Save(rgbSourceStream, encdr); // throws exception "EXIF data object is too big, its size exceeds 64K limit (that is defined by Jpeg standart for APP1 marker data)"
							}
							else
							{
								throw;
							}
						}
					}
					
					// do something else for rgbSourceStream....
				}
			}
        }
		
		private static System.Tuple<ExifDictionary, IptcDictionary> GetMetadata(MemoryStream msInput)
        {
            ExifDictionary orgExif;
            IptcDictionary orgIptc;

            try
            {
                using (var jpegReader = new JpegReader(msInput))
                {
                    orgExif = jpegReader.Exif ?? new ExifDictionary();
                    orgIptc = jpegReader.Iptc ?? new IptcDictionary();
                }
            }
            catch
            {
                try
                {
                    using (var tiffReader = new TiffReader(msInput))
                    {
                        orgExif = tiffReader.Exif ?? new ExifDictionary();
                        orgIptc = tiffReader.Iptc ?? new IptcDictionary();
                    }
                }
                catch
                {
                    // this is not a jepg format or tiff format file. We cannot get the Exif and Iptc data
                    orgExif = new ExifDictionary();
                    orgIptc = new IptcDictionary();
                }
            }
            return new System.Tuple<ExifDictionary, IptcDictionary>(orgExif, orgIptc);
        }
    }

Edited by user Monday, July 1, 2019 1:49:31 PM(UTC)  | Reason: Not specified

Fedor  
#2 Posted : Monday, July 1, 2019 9:36:48 PM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 67 time(s) in 65 post(s)
Hi,

Here is a quote from Wikipedia:

Quote:
Exif metadata are restricted in size to 64 kB in JPEG images because according to the specification, this information must be contained within a single JPEG APP1 segment. Although the FlashPix extensions allow information to span multiple JPEG APP2 segments, these extensions are not commonly used. This has prompted some camera manufacturers to develop non-standard techniques for storing the large preview images used by some digital cameras for LCD review. These non-standard extensions are commonly lost if a user re-saves the image using image editor software, possibly rendering the image incompatible with the original camera that created it. (In 2009, CIPA released the Multi Picture Object specification which addresses this deficiency and provides a standard way to store large previews in JPEG images.[13])


So, it seems that the size of metadata is over 64 kB, and you need to remove some fields to resave the image. Could you send us the file you would like to process? You can submit a case if it is more convenient for you.

Alternatively, we may consider storing of EXIF metadata in multiple JPEG APP segments. We did preliminary research of this task, and we need several work days to implement it.

Edited by user Monday, July 1, 2019 9:39:47 PM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Raymund  
#3 Posted : Tuesday, July 2, 2019 7:16:07 AM(UTC)
Raymund

Rank: Newbie

Groups: Member
Joined: 10/2/2015(UTC)
Posts: 2

Thank you, Fedor

I have created a support case with ID CAS-70661. Please check

And the image is mentioned in the description, but just in case, here is the link (in fact, I don't see any field is large enough to make the metadata size over 64k):
https://www.dropbox.com/...20Deck%20to%20Garage.jpg

Edited by user Friday, July 5, 2019 12:49:35 PM(UTC)  | Reason: Not specified

Fedor  
#4 Posted : Thursday, July 18, 2019 10:41:39 PM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 67 time(s) in 65 post(s)
We fixed this problem in the later version of Graphics Mill that you use ( 7.5.82.0). So, please consider upgrading to the last version, which is backward compatible.
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.