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

Notification

Icon
Error

#large-images #metadata

Options
Go to last post Go to first unread
SebastianR  
#1 Posted : Monday, July 10, 2017 3:35:43 AM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
Joined: 5/10/2017(UTC)
Posts: 33

Thanks: 10 times
Was thanked: 1 time(s) in 1 post(s)
Hello,

I want to save Jpegs with a pipeline. Sadly it has to much Xmp or Exif data, which leads to a JpegMarkerException when I want to save.

While I was using bitmaps, I just catched the exception, removed the data and saved again. Now with pipeline, resaving is no longer an option, because it just takes to long and pipeline elements may be disposed.

Is there a way to get the size of the Exif data Directory and xmp-data or better, wether or not the saving will be successful, while using a pipeline?

Sebastian

Fedor  
#2 Posted : Monday, July 10, 2017 11:52:16 PM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 64 time(s) in 63 post(s)
Could you attach an example of problem JPEG file?
Best regards,

Fedor Skvortsov

SebastianR  
#3 Posted : Tuesday, July 11, 2017 1:41:35 AM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
Joined: 5/10/2017(UTC)
Posts: 33

Thanks: 10 times
Was thanked: 1 time(s) in 1 post(s)
Images have been sent in a private post.

The pipeline is as follows:

Code:
using (var reader = ImageReader.Create())
using (var writer = new JpegWriter())
{
    writer.Exif = reader.Exif; // We need to do this because the Exif may have been changed during the process.
    writer.Xmp = reader.Xmp;
    (reader + writer).Run();
}

I just found out that clearing the image content to white prevents the exception in the case of exif. Also if you don’t set

Code:

writer.Exif = reader.Exif;
writer.Xmp = reader.Xmp;
Fedor  
#4 Posted : Tuesday, July 11, 2017 6:33:34 AM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 64 time(s) in 63 post(s)
We will implement the checking of EXIF/XMP metadata size in the further releases (Aurigma Bug #0023516).

Currently, you can use the following workaround:

Code:
using System;
using System.IO;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Codecs;

class Program
{
	static void Main(string[] args)
	{
		var inputName = "../../../in.tif";
		var outputName = "../../../out.jpg";

		using (var reader = ImageReader.Create(inputName))
		using (var writer = new JpegWriter(outputName))
		{
			writer.Exif = reader.Exif; 

			using (var bitmap = new Bitmap(1, 1, PixelFormat.Format24bppRgb))
			using (var memoryStream = new MemoryStream())
			{
				try
				{
					bitmap.Save(memoryStream, new JpegSettings() { Exif = reader.Exif });
				}
				catch (JpegMarkerException)
				{
					writer.Exif = null;
				}
			}
			

			writer.Xmp = reader.Xmp;

			using (var bitmap = new Bitmap(1, 1, PixelFormat.Format24bppRgb))
			using (var memoryStream = new MemoryStream())
			{
				try
				{
					bitmap.Save(memoryStream, new JpegSettings() { Xmp = reader.Xmp});
				}
				catch (ArgumentException)
				{
					writer.Xmp = null;
				}
			}

			(reader + writer).Run();
		}
	}
}

Edited by user Tuesday, July 11, 2017 6:34:34 AM(UTC)  | Reason: Not specified

Best regards,

Fedor Skvortsov

thanks 1 user thanked Fedor for this useful post.
SebastianR on 7/11/2017(UTC)
SebastianR  
#5 Posted : Tuesday, July 11, 2017 11:05:51 PM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
Joined: 5/10/2017(UTC)
Posts: 33

Thanks: 10 times
Was thanked: 1 time(s) in 1 post(s)
Thank you for your fast response and excellent service. You make working with GraphicsMill even better.

thanks 1 user thanked SebastianR for this useful post.
Fedor on 7/12/2017(UTC)
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.