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
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Could you attach an example of problem JPEG file? |
Best regards, Fedor Skvortsov
|
|
|
|
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;
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 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](/Themes/aurigma/heart_small.png) 1 user thanked Fedor for this useful post.
|
|
|
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](/Themes/aurigma/heart_small.png) 1 user thanked SebastianR for this useful post.
|
|
|
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.