<div dir="ltr">Thanks all for your feedback,

now I understand the reason for the error. <div>Even thanks for the fix. 

I think it will be in place in the next GDAL release, am I correct?</div><div><br><div><div><div>For the time being I'm using the GDAL_SKIP environment variable (thanks Andrew for the hint) and it works.<br><div><br></div></div></div></div></div><div>Calogero</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 11, 2020 at 11:58 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div style="font-family:monospace;font-size:9pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px">On jeudi 10 septembre 2020 23:16:22 CEST jratike80 wrote:</p>
<p style="margin:0px;text-indent:0px">> Calogero Mauceri wrote</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> > I'm not sure why it tries to open the ENVI file using the OpenJPEG reader.</p>
<p style="margin:0px;text-indent:0px">> > Anyway I'm using GDAL 2.4.4 and OpenJPEG 2.3.0. I tried GDAL 3.1.2, but I</p>
<p style="margin:0px;text-indent:0px">> > get the same error.</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> GDAL is quessing the driver by the file name extension and starts trying</p>
<p style="margin:0px;text-indent:0px">> them one by one, in the order they appear in the list of supported drivers.</p>
<p style="margin:0px;text-indent:0px">> ENVI files are often named as .bsq, .bip, or .bil and then the guess is</p>
<p style="margin:0px;text-indent:0px">> usually right. However, .IMG is used by several other drivers as well.</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Actually most GDAL drivers avoid as much as possible relying on extensions, but rather on 'signatures' in file content. Of course with the ENVI driver where the filename passed for opening is the one of the raw raster content, there's no such signature, and thus this driver is tried after all other content-based drivers, because it has to detect the .hdr sidecar file as well. </p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> The JP2OpenJPEG driver may be too eager to open images with any name</p>
<p style="margin:0px;text-indent:0px">> extension. I modified your command a bit into</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">The issue was actually true of several JPEG2000 capable drivers that can open a raw JPEG2000 codestream, and identified it with the first 2 bytes only. But actually the first 4 bytes are fixed, so in</p>
<p style="margin:0px;text-indent:0px"><a href="https://github.com/OSGeo/gdal/pull/2931" target="_blank">https://github.com/OSGeo/gdal/pull/2931</a> I detect them, which should considerably reduce the likelihood of false identification</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Even</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">-- </p>
<p style="margin:0px;text-indent:0px">Doing Open Source mostly as a greedy capitalist,</p>
<p style="margin:0px;text-indent:0px">as a hobbyist by accident at times.</p>
<p style="margin:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></div>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Calogero Mauceri<br>Software Engineer<br><br>Applied Coherent Technology Corporation (ACT)<br><a href="http://www.actgate.com" target="_blank">www.actgate.com</a><br></div></div>