@@ -10116,6 +10116,30 @@ void CLASS jpeg_thumb()
10116
10116
free (thumb );
10117
10117
}
10118
10118
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
+
10119
10143
void CLASS write_ppm_tiff ()
10120
10144
{
10121
10145
struct tiff_hdr th ;
@@ -10275,7 +10299,7 @@ int CLASS main (int argc, const char **argv)
10275
10299
case 'P' : bpfile = argv [arg ++ ]; break ;
10276
10300
case 'K' : dark_frame = argv [arg ++ ]; break ;
10277
10301
case 'z' : timestamp_only = 1 ; break ;
10278
- case 'e' : thumbnail_only = 1 ; break ;
10302
+ case 'e' : thumbnail_only ++ ; break ;
10279
10303
case 'i' : identify_only = 1 ; break ;
10280
10304
case 'c' : write_to_stdout = 1 ; break ;
10281
10305
case 'v' : verbose = 1 ; break ;
@@ -10552,6 +10576,8 @@ int CLASS main (int argc, const char **argv)
10552
10576
write_ext = ".tiff" ;
10553
10577
else
10554
10578
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 ;
10555
10581
ofname = (char * ) malloc (strlen (ifname ) + 64 );
10556
10582
merror (ofname , "main()" );
10557
10583
if (write_to_stdout )
0 commit comments