I have some JPG with jfif that Lightroom will not read

Started by cwinte, July 05, 2021, 11:32:16 AM

Previous topic - Next topic

cwinte

I can open and save in image editor, all OK except file larger and I loose original dates etc.
Here's what I see in the files:
After running exiftool "-exif:all<all" "-thumbnailimage" /Volumes/Seagate5TA_Main/SYNC\ ZONE/LIGHTROOM\ IMAGES/2020/2020-11-26
Newly created derived file (which still does not read into Lightroom)
$ exiftool -a -g /Volumes/Seagate5TA_Main/SYNC\ ZONE/LIGHTROOM\ IMAGES/2020/2020-11-26/IMG_2268.JPG
---- ExifTool ----
ExifTool Version Number         : 10.13
---- File ----
File Name                       : IMG_2268.JPG
Directory                       : /Volumes/Seagate5TA_Main/SYNC ZONE/LIGHTROOM IMAGES/2020/2020-11-26
File Size                       : 297 kB
File Modification Date/Time     : 2021:07:05 16:13:15+01:00
File Access Date/Time           : 2021:07:05 16:17:46+01:00
File Inode Change Date/Time     : 2021:07:05 16:13:15+01:00
File Permissions                : rwxr-xr-x
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Image Width                     : 1200
Image Height                    : 1599
Encoding Process                : Progressive DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
---- JFIF ----
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
---- EXIF ----
X Resolution                    : 1
Y Resolution                    : 1
Resolution Unit                 : None
Y Cb Cr Positioning             : Centered
---- Composite ----
Image Size                      : 1200x1599
Megapixels                      : 1.9

Original file:
exiftool -a -g /Volumes/Seagate5TA_Main/SYNC\ ZONE/LIGHTROOM\ IMAGES/2020/2020-11-26/IMG_2268.JPG_original
---- ExifTool ----
ExifTool Version Number         : 10.13
---- File ----
File Name                       : IMG_2268.JPG_original
Directory                       : /Volumes/Seagate5TA_Main/SYNC ZONE/LIGHTROOM IMAGES/2020/2020-11-26
File Size                       : 297 kB
File Modification Date/Time     : 2020:11:26 15:13:09+00:00
File Access Date/Time           : 2021:07:05 16:21:46+01:00
File Inode Change Date/Time     : 2021:06:29 20:23:58+01:00
File Permissions                : rwxr-xr-x
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Image Width                     : 1200
Image Height                    : 1599
Encoding Process                : Progressive DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
---- JFIF ----
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
---- Composite ----
Image Size                      : 1200x1599
Megapixels                      : 1.9

Neither reads into LightRoom (6.8 on MacOS 10.11.6) but a different one I edited will (NB larger and dates modified, not great for date archive):
exiftool -a -g /Volumes/Seagate5TA_Main/SYNC\ ZONE/LIGHTROOM\ IMAGES/2020/2020-11-26/IMG_2268GC.jpg
---- ExifTool ----
ExifTool Version Number         : 10.13
---- File ----
File Name                       : IMG_2268GC.jpg
Directory                       : /Volumes/Seagate5TA_Main/SYNC ZONE/LIGHTROOM IMAGES/2020/2020-11-26
File Size                       : 457 kB
Resource Fork Size              : 423 kB
File Modification Date/Time     : 2021:07:05 16:13:15+01:00
File Access Date/Time           : 2021:07:05 16:16:25+01:00
File Inode Change Date/Time     : 2021:07:05 16:13:15+01:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Image Width                     : 1200
Image Height                    : 1599
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
---- JFIF ----
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 72
Y Resolution                    : 72
---- EXIF ----
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Y Cb Cr Positioning             : Centered
---- XMP ----
XMP Toolkit                     : XMP Core 4.4.0
---- Composite ----
Image Size                      : 1200x1599
Megapixels                      : 1.9


Is it to do with Baseline vs Progressive DCT and can I change that without image rework/degrade etc? with exiftool (I suspect not)?

A BIG THANKS!
Colin

Phil Harvey

Hi Colin,

Can you post a sample file that doesn't load into LightRoom?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: cwinte on July 05, 2021, 11:32:16 AM
I can open and save in image editor, all OK except file larger and I loose original dates etc.

And the image quality has degraded.  Jpegs are a lossy format and every time you load and save a new copy, more image data is lost.  What you want to use is a program with Lossless Jpg transformations based upon the JpegTran code. You don't mention your OS, but I'm guessing Mac?  If so, you could try XNView or grab the jpegtran command line program.  Here's a page that talks about using jpegtran.

Quote
After running exiftool "-exif:all<all" "-thumbnailimage" /Volumes/Seagate5TA_Main/SYNC\ ZONE/LIGHTROOM\ IMAGES/2020/2020-11-26

I'm not sure what you're trying to do with that command.  It tries to copy tags into the exif block, but that's not likely to change much, as it would mostly be copying the exif tags back onto themselves.  And the "-thumbnailimage" part does nothing.

QuoteIs it to do with Baseline vs Progressive DCT and can I change that without image rework/degrade etc? with exiftool (I suspect not)?

Lightroom shouldn't have a problem with a progressive jpeg.  And the original image didn't even have an EXIF block according to that output.

Exiftool only works with metadata, so it can't change the image data, which seems to be the problem here.

I would suggest using XNView MP (link above) to rewrite the problem jpegs.  Load the directory with the files, select Tools menu->JPEG lossless transformations->Rotate based on EXIF orientation field   This will rewrite the jpegs using the jpegtran code.  As a side effect, the jpegs will likely be a bit smaller due to the jpeg optimization code in jpegtrans.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

cwinte

First, thanks to both for responses.

I had previously looked around (git etc) for tools to work inside JPEGs and not turned up jpegtran etc and like the idea so have built and installed that/them (yes macOS, I did mention LR and OS versions but hidden between all the output). I don't seem to preserve original File Modification Date/Time which I had hoped for (sometimes there's a -p -preserve switch available). I will dig around a bit more...

To preserve file date metadata could I maybe use Phil's script at https://exiftool.org/forum/index.php?topic=1846.msg8031#msg8031
or is it more an OS filesystem work around? {is it bad to have started multiple sub-threads here? one per posting is better?}

The file output from "jpegtran -verbose -progressive -optimise -copy all IMG_2269tr.JPG > IMG_2269done.JPG" shows up fine in LR although not with the original date which is my residual challenge now! I will dig around a bit more... File size dropped from 401k to 400k.

Not sure this forums options for sharing a file will preserve what is needed, will try attach below ...

Phil Harvey

StarGeek is right.  The problem has nothing to do with the metadata in this file.  In fact, there is nothing really useful -- only JFIF metadata in this file.  You can use ExifTool to copy this with this command:

exiftool -tagsfromfile SRCFILE -jfif:all DSTFILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

cwinte

OK, I see that.
Can you suggest a strategy/order of actions that get me the readable JPG format with original file dates?

I tried to fix image data with
  jpegtran -verbose -progressive -optimise -copy all IMG_2269tr.JPG > IMG_2269done.JPG
and then fix dates with
  exiftool -tagsfromfile -P IMG_2269tr.JPG -jfif:all IMG_2269done.JPG

But I still end up with a file dated today!

PS or Side note: MacOS is quite happy to preview and quick-view the original jfif format IMG_2269tr.JPG file, it seems just LR that shows flat grey (so far)..

cwinte

AH, a bit of a discovery. LR will swap onto a newer version of a file and retain old dates if I do:
change filenames on files that do not read *.JPG -> *.DNR (does not read, say)
At this point LR shows the grey preview with a missing [!] mark...
then jpegtran to the original *.JPG
When in LR visit the grey missing images and LR detects the new files and adopts them, although they are noted as metadata conflicted in the Metadata panel. Clicking the "burger icon" Resolve conflict offers to update metadata(base) in LR or update the file...
This does insert new metadata about LR doing the changes...

Not a fluid process for lots of files but it works for the few I have.

Would still be nice to have some fix in place option somehow.
Also jpegtran only seems to handle single files at a time and must >outfile - also not very efficient working (for me), guess it could be scripted...

StarGeek

Quote from: cwinte on July 06, 2021, 08:40:37 AM
and then fix dates with
  exiftool -tagsfromfile -P IMG_2269tr.JPG -jfif:all IMG_2269done.JPG

The JFIF block doesn't contain a date.  I would suggest using this command to also copy the file system timestamps and it will do it as a batch
exiftool -TagsFromFile %-.4f.%e -JFIF:All -FileCreateDate -FileModifyDate /path/to/doneFiles/*done*

The %-.4f.%e part looks for a file with the same name as the file being processed but without the last four letters of the base name, i.e. it removes the "done" part of the base name.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).