This question is the same as in the archived thread Make JPEG file DCF compatible (https://exiftool.org/forum/index.php?topic=2228.0).
For now, I create a test image in ImageMagick and try to make it viewable in the phone. So far I have not succeeded, although the Exif data looks very similar. The image R0000349.JPG (https://archive.org/details/r-0000349) was shot with my Ricoh GR III digicam. Here is what I tried:
$ convert -size 6000x4000 radial-gradient:red-blue -sampling-factor 4:2:2 S0000422.JPG
$ exiftool -TagsFromFile R0000349.JPG -all:all -unsafe -XML:All S0000422.JPG
$ exiftool R0000349.JPG | sort >R0000349.EXIF
$ exiftool S0000422.JPG | sort >S0000422.EXIF
$ diff R0000349.EXIF S0000422.EXIF
49,52c49,52
< File Access Date/Time : 2020:08:01 13:49:29+08:00
< File Inode Change Date/Time : 2020:08:01 13:49:29+08:00
< File Modification Date/Time : 2020:08:01 13:49:29+08:00
< File Name : R0000349.JPG
---
> File Access Date/Time : 2020:08:01 13:49:35+08:00
> File Inode Change Date/Time : 2020:08:01 13:49:35+08:00
> File Modification Date/Time : 2020:08:01 13:49:35+08:00
> File Name : S0000422.JPG
54c54
< File Size : 11 MB
---
> File Size : 448 kB
80a81
> JFIF Version : 1.01
145c146
< Thumbnail Offset : 32066
---
> Thumbnail Offset : 23362
The camera cannot display S0000422.JPG.
As a workaround, I found I can open and save S0000422.JPG using Sony's Imaging Edge Desktop (https://imagingedge.sony.net/en-us/ie-desktop.html). Optionally, if I copy the Exif data using ExifTool as above, the image will still display in the camera. However, Imaging Edge Desktop does not run on Linux, and as far as I can tell, there is no batch processing option.
PS: See also my crosspost Make image viewable in camera? (https://github.com/ImageMagick/ImageMagick/discussions/2349) to the ImageMagick discussion forum.
I think you need to look a bit more in detail at the metadata. At the very least you should add -a -G1 to your command, but it would be better to compare the -v2 output so you can see the order of the JPEG segments. It is probably crucial that the first segment is the same.
- Phil
Adding -a -G1 shows additional JFIF tags, which are only in the image generated by ImageMagick:
$ convert -size 6000x4000 radial-gradient:red-blue -sampling-factor 4:2:2 S0000422.JPG
$ exiftool -TagsFromFile R0000349.JPG -all:all -unsafe -XML:All S0000422.JPG
1 image files updated
$ exiftool -a -G1 R0000349.JPG | sort >R0000349.EXIF
$ exiftool -a -G1 S0000422.JPG | sort >S0000422.EXIF
$ diff R0000349.EXIF S0000422.EXIF
68c68
< [IFD1] Thumbnail Offset : 32066
---
> [IFD1] Thumbnail Offset : 23362
72a73,76
> [JFIF] JFIF Version : 1.01
> [JFIF] Resolution Unit : None
> [JFIF] X Resolution : 1
> [JFIF] Y Resolution : 1
164,166c168,170
< [System] File Inode Change Date/Time : 2020:08:01 19:11:02+08:00
< [System] File Modification Date/Time : 2020:08:01 19:11:02+08:00
< [System] File Name : R0000349.JPG
---
> [System] File Inode Change Date/Time : 2020:08:01 19:11:14+08:00
> [System] File Modification Date/Time : 2020:08:01 19:11:14+08:00
> [System] File Name : S0000422.JPG
168c172
< [System] File Size : 11 MB
---
> [System] File Size : 448 kB
Then I tried with -v2, see below. Here fields like Make are shown to differ, although they look identical. Anyhow, when I convert the JPEG using Sony's Imaging Edge Desktop, Make may not even be present, and definitely it won't be Ricoh. For the rest of the tags, I don't really know what to look for. There is BindaryData directory, but only in the image created with ImageMagick.
[felix@felix-arch tmp]$ exiftool -v2 R0000349.JPG | sort >R0000349.EXIF
[felix@felix-arch tmp]$ exiftool -v2 S0000422.JPG | sort >S0000422.EXIF
[felix@felix-arch tmp]$ diff R0000349.EXIF S0000422.EXIF
5c5
< | 0) Make = RICOH IMAGING COMPANY, LTD.
---
> | 0) Make = RICOH IMAGING COMPANY, LTD.
41c41
< | | 1) FNumber = 3.5 (35/10)
---
> | | 1) FNumber = 3.5 (7/2)
43c43
< | 1) Model = RICOH GR III
---
> | 1) Model = RICOH GR III
114c114
< | 4) ThumbnailOffset = 32054
---
> | 4) ThumbnailOffset = 23332
145c145
< | 6) Software = RICOH GR III Ver. 1.30
---
> | 6) Software = RICOH GR III Ver. 1.30
183a184
> + [BinaryData directory, 9 bytes]
222,225c223,226
< FileAccessDate = 1596280290
< FileInodeChangeDate = 1596280262
< FileModifyDate = 1596280262
< FileName = R0000349.JPG
---
> FileAccessDate = 1596280300
> FileInodeChangeDate = 1596280274
> FileModifyDate = 1596280274
> FileName = S0000422.JPG
227c228
< FileSize = 11047650
---
> FileSize = 459016
237,241c238,246
< JPEG APP1 (39226 bytes):
< JPEG APP7 (57406 bytes):
< JPEG DHT (416 bytes):
< JPEG DQT (130 bytes):
< JPEG DRI (2 bytes):
---
> | JFIFVersion = 1 1
> JPEG APP0 (14 bytes):
> JPEG APP1 (30500 bytes):
> JPEG DHT (21 bytes):
> JPEG DHT (21 bytes):
> JPEG DHT (23 bytes):
> JPEG DHT (27 bytes):
> JPEG DQT (65 bytes):
> JPEG DQT (65 bytes):
272a278
> | ResolutionUnit = 0
281a288
> | - Tag 0x0000 (2 bytes, int8u[2])
296a304
> | - Tag 0x0002 (1 bytes, int8u[1])
304a313
> | - Tag 0x0003 (2 bytes, int16u[1])
309a319
> | - Tag 0x0005 (2 bytes, int16u[1])
314a325
> | - Tag 0x0007 (1 bytes, int8u[1])
316a328
> | - Tag 0x0008 (1 bytes, int8u[1])
408,409c420,421
< | - Tag 0x010f (30 bytes, string[30])
< | - Tag 0x0110 (20 bytes, string[20])
---
> | - Tag 0x010f (28 bytes, string[28])
> | - Tag 0x0110 (13 bytes, string[13])
420c432
< | - Tag 0x0131 (30 bytes, string[30])
---
> | - Tag 0x0131 (23 bytes, string[23])
492c504
< | | - Tag 0x927c (30720 bytes, undef[30720])
---
> | | - Tag 0x927c (22086 bytes, undef[22086])
495,496c507,508
< | | - Tag 0xa002 (4 bytes, int32u[1])
< | | - Tag 0xa003 (4 bytes, int32u[1])
---
> | | - Tag 0xa002 (2 bytes, int16u[1])
> | | - Tag 0xa003 (2 bytes, int16u[1])
512a525,526
> | ThumbnailHeight = 0
> | ThumbnailWidth = 0
516a531
> | XResolution = 1
517a533
> | YResolution = 1
What about the Exif tag Compression?
In the image created by ImageMagic, this tag does not exist. In the image from the camera, it says: JPEG (old-style)
I don't understand what old-syle refers to.
Quote from: feklee on August 01, 2020, 08:59:21 AM
In the image created by ImageMagic, this tag does not exist. In the image from the camera, it says: JPEG (old-style)
I don't understand what old-syle refers to.
It refers to the embedded thumbnail image, not to any difference in the way the image is encoded.
Your image still has the JFIF block. As I commented in your StackExchange (https://photo.stackexchange.com/questions/118119/how-to-make-a-jpg-files-dcf-compatible-command-line) post, you should remove that as mentioned in the thread you linked above.
Quote from: StarGeek on August 01, 2020, 10:58:49 AM
QuoteI don't understand what old-syle refers to.
It refers to the embedded thumbnail image, not to any difference in the way the image is encoded.
Phew, finally someone clarifies this. Thanks!
QuoteYour image still has the JFIF block. As I commented in your
StackExchange (https://photo.stackexchange.com/questions/118119/how-to-make-a-jpg-files-dcf-compatible-command-line)
post, you should remove that as mentioned in the thread you linked
above.
Thanks again. In fact I tried that out, but it didn't do the trick by itself. Later I looked at other tags, and found that the chroma sub sampling differs. So I changed that by adding
-sampling-factor 4:2:2 on the ImageMagick command line. Only when I copied the Exif data afterwards, I forgot your
-JFIF:ALL=. Now, with it added, it finally works, hurray!
$ convert -size 6000x4000 radial-gradient:red-blue -sampling-factor 4:2:2 S0000422.JPG
$ exiftool -TagsFromFile R0000349.JPG -all:all -unsafe -XML:All -JFIF:ALL= S0000422.JPG
What needs to be done next is to fix the thumbnail, because the thumbnail that shows up is the one from
R0000349.JPG, and this is confusing. Hopefully, this is not an issue now with the old-style encoding.
Fixing the thumbnail was straight forward:
$ convert -size 6000x4000 radial-gradient:red-blue -sampling-factor 4:2:2 S0000422.JPG
$ exiftool -TagsFromFile R0000349.JPG -all:all -unsafe -XML:All -JFIF:ALL= S0000422.JPG
$ convert -sampling-factor 4:2:2 -resize 160 S0000422.JPG S0000422_THUMB.JPG
$ exiftool "-ThumbnailImage<=S0000422_THUMB.JPG" S0000422.JPG
Next steps:
- Get it to work with non 3:2 aspect ratios.
- Perhaps not super important: Get rid of the need to copy Exif data from an existing file.
- Script it all.
Non 3:2 aspect ratios are also no problem:
$ convert S0000422.JPG -resize 160x120 -background black -gravity center -extent 160x120 -sampling-factor 4:2:2 S0000422_THUMB.JPG
Scripting should be straight forward, and copying the Exif data from an existing file may actually be a smart thing to do.
Quote from: feklee on August 01, 2020, 10:52:31 PM
Quote from: StarGeek on August 01, 2020, 10:58:49 AM
QuoteI don't understand what old-syle refers to.
It refers to the embedded thumbnail image, not to any difference in the way the image is encoded.
Phew, finally someone clarifies this. Thanks!
From what I understand, the entire
IFD1 part of the EXIF block is all related to the embedded thumbnail image.