Skip to content

Commit 5ee59db

Browse files
committed
Output offset+length for JPEG thumbs.
1 parent 11f6297 commit 5ee59db

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

dcraw.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10116,6 +10116,30 @@ void CLASS jpeg_thumb()
1011610116
free (thumb);
1011710117
}
1011810118

10119+
void CLASS jpeg_offset()
10120+
{
10121+
char thumb[12];
10122+
ushort exif[5];
10123+
struct tiff_hdr th;
10124+
10125+
tread (thumb, 1, 12, ifp);
10126+
fputc (0xff, ofp);
10127+
fputc (0xd8, ofp);
10128+
if (strcmp (thumb+6, "Exif")) {
10129+
memcpy (exif, "\xff\xe1 Exif\0\0", 10);
10130+
exif[1] = htons (8 + sizeof th);
10131+
twrite (exif, 1, sizeof exif, ofp);
10132+
tiff_head (&th, 0);
10133+
twrite (&th, 1, sizeof th, ofp);
10134+
}
10135+
10136+
fputc (0xff, ofp);
10137+
fputc (0xd9, ofp);
10138+
UINT64 bin[] = {thumb_offset+2, thumb_length-2};
10139+
twrite (&bin, sizeof(UINT64), 2, ofp);
10140+
twrite ("OFfSeTLeNgtH", 1, 12, ofp);
10141+
}
10142+
1011910143
void CLASS write_ppm_tiff()
1012010144
{
1012110145
struct tiff_hdr th;
@@ -10275,7 +10299,7 @@ int CLASS main (int argc, const char **argv)
1027510299
case 'P': bpfile = argv[arg++]; break;
1027610300
case 'K': dark_frame = argv[arg++]; break;
1027710301
case 'z': timestamp_only = 1; break;
10278-
case 'e': thumbnail_only = 1; break;
10302+
case 'e': thumbnail_only++; break;
1027910303
case 'i': identify_only = 1; break;
1028010304
case 'c': write_to_stdout = 1; break;
1028110305
case 'v': verbose = 1; break;
@@ -10552,6 +10576,8 @@ int CLASS main (int argc, const char **argv)
1055210576
write_ext = ".tiff";
1055310577
else
1055410578
write_ext = ".pgm\0.ppm\0.ppm\0.pam" + colors*5-5;
10579+
if (thumbnail_only > 1 && write_fun == &CLASS jpeg_thumb)
10580+
write_fun = &CLASS jpeg_offset;
1055510581
ofname = (char *) malloc (strlen(ifname) + 64);
1055610582
merror (ofname, "main()");
1055710583
if (write_to_stdout)

0 commit comments

Comments
 (0)