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

JPEG modified with GM validation error

Hi friends,

I continue with my project editing TIFF and JPEG images. I found what I think is a new bug.
As I told in another post, I use Jhove for digital objects validation. The problem now is with JPEG files.

If I validate the original JPEG, the result is OK. But when I edit the image with GM and then validate the output JPEG I have several error messages:

(Value offset not word-aligned: 133) and next.

<?xml version="1.0" encoding="utf-8"?>
<jhove xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://hul.harvard.edu/ois/xml/ns/jhove" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/jhove http://hul.harvard.edu/ois/xml/xsd/jhove/1.6/jhove.xsd" name="JhoveView" release="1.20.1" date="2018-03-29">
 <date>2018-05-14T11:00:36+02:00</date>
 <repInfo uri="E:%5CTEST%5CSALIDA%5C0005_cortada_con_error.jpg">
  <reportingModule release="1.4" date="2018-03-29">JPEG-hul</reportingModule>
  <lastModified>2018-05-11T09:57:29+02:00</lastModified>
  <size>438221</size>
  <format>JPEG</format>
  <version>1.01</version>
  <status>Well-Formed and valid</status>
  <sigMatch>
  <module>JPEG-hul</module>
  </sigMatch>
  <messages>
   <message offset="30" severity="info">Value offset not word-aligned: 133</message>
   <message offset="42" severity="info">Value offset not word-aligned: 189</message>
   <message offset="54" severity="info">Value offset not word-aligned: 197</message>
   <message offset="78" severity="info">Value offset not word-aligned: 205</message>
  </messages>
  <mimeType>image/jpeg</mimeType>
  <profiles>
   <profile>JFIF</profile>
  </profiles>


I use the next code for JPEG edition:

var exif = new Aurigma.GraphicsMill.Codecs.ExifDictionary();
var iptc = new Aurigma.GraphicsMill.Codecs.IptcDictionary();
                   
   if (procesar_exif == false)
   {
    exif = reader.Exif;
    exif.Remove(ExifDictionary.Thumbnail);
    writer.Exif = exif;
   }
   else
   {
    exif = reader.Exif;
    exif.Remove(ExifDictionary.Thumbnail);
    if (reader.Iptc != null) iptc = reader.Iptc;
    if (checkBoxEXIF.Enabled) writer.Exif = InsertarEXIF(exif);
    if (checkBoxIPTC.Checked) writer.Iptc = InsertarIPTC(iptc);
    if (reader.Xmp != null) writer.Xmp = reader.Xmp;
   }


then I crop and add a border to the input image as shown:

using (var borderColor = RgbColor.Black)
using (var generator = new ImageGenerator(crop.Rectangle.Width + (int)border_size * 2, crop.Rectangle.Height + (int)border_size * 2, reader.PixelFormat, borderColor))
using (var blender = new Blender())
{
if (resolution == 0)       // DON´T CHANGE INPUT RESOLUTION
{
blender.TopImage = reader.Frames[0] + crop;
blender.X = (int)border_size;
blender.Y = (int)border_size;
generator.DpiX = reader.DpiX;
generator.DpiY = reader.DpiY;
         try
         {
         Pipeline.Run(generator + blender + writer);
         crop.Dispose();
         exif.Dispose();
         iptc.Dispose();
         errorRectangulo = false;
         }
         catch (Aurigma.GraphicsMill.PipelineException e)
         {
         ShowErrorGM(e);
         }
}
else        // CHANGE INPUT RESOLUTION
{
float ratio = resolution / reader.DpiX;                                                     // RATIO CALC     
float border_size_tmp = border_size * ratio;                                         // APPLY RATIO TO BORDER
border_size = (int)border_size_tmp;
float Pixels_X = ((rectangulo.Width / reader.DpiX) * resolution);           //CALC SIZE FOR SCALE
float Pixels_Y = ((rectangulo.Height / reader.DpiY) * resolution);

generator.DpiX = resolution;
generator.DpiY = resolution;
generator.Width = (int)Pixels_X + (int)border_size * 2;
generator.Height = (int)Pixels_Y + (int)border_size * 2;
resize.Width = (int)Pixels_X;
resize.Height = (int)Pixels_Y;
resize.InterpolationMode = ResizeInterpolationMode.Medium;

blender.TopImage = reader.Frames[0] + crop + resize;
blender.X = (generator.Width - resize.Width) / 2;
blender.Y = (generator.Height - resize.Height) / 2;

     try
     {
      Pipeline.Run(generator + blender + writer);
      crop.Dispose();
      exif.Dispose();
      iptc.Dispose();
      errorRectangulo = false;
      }
      catch (Aurigma.GraphicsMill.PipelineException e)
     {
     ShowErrorGM(e);
     }
}
}


After this edition, the validation error is present. Even If I don´t change the EXIF or IPTC.
When I apply the same code adapted to TIFF images I have no validation errors, it only happens with JPEG files.

Attached input JPEG images: attach #1382
Attached output JPEG image: attach #1383

I need your help. 🤦 Thanks in advance. o:)
Hi,

As I understand, these messages are informal, and they all have "info" severity. The overall status is "Well-Formed and valid".

Jhove shows me similar output for the same actions made in Adobe Photoshop. I think word-alignment missing is not a critical issue. My suggestion is to setup Jhove to ignore info messages.
Hi Eugene, thanks for your reply.

I really don't know how configure Jhove to ignore this info messages, and although the problem is the same when I edit the image with photoshop I'm sure that something is wrong in Photoshop too.
When we use another libraries (pure C# for example) we have not this problem.

I´m not saying that GM are bad libraries, not at all, but I almost would like to know what does that messages means to try repair the images. I really don't know what TAGS are bad aligned.

Thanks so much in advance.
On this page, I see a logging level setting for Jhove. I'm not sure how you use it, but it might be helpful to try to change this value.

The problem is actually with EXIF saving. EXIF tags should be saved in TIFF format. TIFF format means that a value offset is expected to begin on a word boundary, i.e., to be an even number. But in practice, probably all modern software works fine even with unaligned offsets.

Anyway, we'll consider to implement it in future versions. Thanks for posting.
Thanks a lot Eugene.
I will learn about the JHOVE logging level configuration. I will appreciate if finally your team decide repair the unaligned offsets for JPEG images.

Best regards 😉