<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Arial monospaced for SAP";
        panose-1:2 11 6 9 2 2 2 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I have a very old GDAL based tool I wrote that creates JPEG thumbnails for GeoTiff&#8217;s. Since the GeoTiff&#8217;s can be any size and I used a perl script to compute the aspect ratio so I can center a reduced size image in a square thumbnail.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I&#8217;m looking for any suggestions as to how I can look into the problem which is described below.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>This has been running for years. Recently a customer who receives these started scanning the JPG&#8217;s for security threats. Turns out that the JPG&#8217;s I&#8217;ve been writing have garbage data after the JPEG EOI marker.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Since our production system has a very old version I upgraded GDAL to 1.8.1 and have observed the same problem. Turns out it appears to be VRT related and only happens with single band (black/white imagery).<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>If I use gdal_tranlsate to just translate the image to JPEG I get a properly placed EOI (d9ff):<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>[ealpert@sbsenoklgmt07] PACK $&nbsp; gdal_translate -of JPEG 1020010016BB5500.tif 1020010016BB5500_new.jpg<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>Input file size is 1356, 7444<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0...10...20...30...40...50...60...70...80...90...100 - done.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>ealpert@sbsenoklgmt07] PACK $ od -t x2 1020010016BB5500_new.jpg | tail<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610460 288a 8aa2 a228 288a 8aa2 a228 288a 8aa2<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610500 a228 288a 8aa2 a228 288a 8aa2 a228 288a<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610520 8aa2 a228 288a 8aa2 a228 288a 8aa2 a228<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610540 288a 8aa2 a228 288a 8aa2 a228 288a 8aa2<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610560 a228 288a 8aa2 a228 288a 8aa2 a228 288a<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610600 8aa2 a228 288a 8aa2 a228 288a 8aa2 a228<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610620 288a 8aa2 a228 288a 8aa2 a228 288a 8aa2<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610640 a228 288a 8aa2 a228 288a 8aa2 a228 2b8a<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>10610660 <b><span style='color:red'>d9ff<o:p></o:p></span></b></span></p><p class=MsoNormal><b><span style='font-family:"Arial monospaced for SAP";color:red'><o:p>&nbsp;</o:p></span></b></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>If I create a VRT to center the image then use gdal_translate to convert I get the following error message and the JPEG has garbage at the end but can still be viewed without any problems in all applications:<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>ERROR:<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>bit length overflow<o:p></o:p></p><p class=MsoNormal>code 3 bits 6-&gt;7<o:p></o:p></p><p class=MsoNormal><br>VRT: <o:p></o:p></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&lt;VRTDataset rasterXSize=&quot;1024&quot; rasterYSize=&quot;1024&quot;&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp; &lt;NoDataValue&gt;255&lt;/NoDataValue&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp; &lt;VRTRasterBand dataType=&quot;Byte&quot; band=&quot;1&quot;&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'> &nbsp;&nbsp;&nbsp;&lt;ColorInterp&gt;Gray&lt;/ColorInterp&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp; &lt;NoDataValue&gt;255&lt;/NoDataValue&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp; &lt;ComplexSource&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;NODATA&gt;0&lt;/NODATA&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SourceFilename relativeToVRT=&quot;1&quot;&gt;./1020010016BB5500.tif&lt;/SourceFilename&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SourceBand&gt;1&lt;/SourceBand&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SrcRect xOff=&quot;0&quot; yOff=&quot;0&quot; xSize=&quot;1356&quot; ySize=&quot;7444&quot;/&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;DstRect xOff=&quot;419&quot; yOff=&quot;0&quot; xSize=&quot;186&quot; ySize=&quot;1024&quot;/&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp;&nbsp;&nbsp; &lt;/ComplexSource&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&nbsp; &lt;/VRTRasterBand&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>&lt;/VRTDataset&gt;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>[ealpert@sbsenoklgmt07] PACK $ gdal_translate -of JPEG test.vrt test.jpg<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>Input file size is 1024, 1024<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0...10...20...30...40...50...60...70...80...90...100 - done.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>bit length overflow<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>code 3 bits 6-&gt;7<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>[ealpert@sbsenoklgmt07] PACK $ od -t x2 test.jpg | tail<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231300 90bb 1db7 3ee6 d116 d6fe f50c a157 126c<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231320 ff32 6f98 fb44 9a7f 1f57 7db8 9f90 99ff<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231340 047e 65ce b9f3 fe78 cdcf 4137 e390 105f<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231360 bfaf f372 1fed bd27 a8fe 002b 6c9d bbff<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231400 163d 637d bfe7 b716 ebfe ff7a f6a6 97c3<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231420 fad2 fb37 16fa f160 b7fe ebab 2e5f f985<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231440 ef6f f9b1 b347 293b 1037 9fbe 416f 697b<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>0231460 b1fd 84ea 8b9b 690b 13ff 5707 07fc df17<o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial monospaced for SAP";color:red'>0231500 ef84 087f 870e e51b 0127 0000<o:p></o:p></span></b></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'>Note there is no EOI marker. <o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-family:"Arial monospaced for SAP"'><o:p>&nbsp;</o:p></span></p></div><PRE>This electronic communication and any attachments may contain confidential and proprietary 
information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee 
responsible for delivering this communication to the intended recipient, or if you have received 
this communication in error, please do not print, copy, retransmit, disseminate or 
otherwise use the information. Please indicate to the sender that you have received this 
communication in error, and delete the copy you received. DigitalGlobe reserves the 
right to monitor any electronic communication sent or received by its employees, agents 
or representatives.
</PRE></body></html>