<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Thanks for the info. I probably should
have mentioned that I'm working in C++ on windows by the way. I'm
working with NITF images that are simply wrapped jpegs that are in
one piece. For now, I just need to read the NITF file and send
the jpeg image data over the network. Temporarily, I'm just going
to use the CreateCopy function to copy the image data to a jpeg
file, then re-read it into my program then send it over the
network. <br>
<div class="moz-signature"><br>
<font color="grey" face="serif" size="2">
Joe Lyga<br>
Software Engineer<br>
Balfour Technologies LLC and VCORE Solutions LLC<br>
Morrelly Homeland Security Center<br>
510 Grumman Road West, Suite 212, Bethpage NY 11714<br>
Phone: (516) 513-0030<br>
<i>"Innovations in Mission Critical Visualization with
fourDscape®"</i></font></div>
On 7/10/2012 1:45 PM, Even Rouault wrote:<br>
</div>
<blockquote
cite="mid:201207101945.49549.even.rouault@mines-paris.org"
type="cite">
<pre wrap="">Le mardi 10 juillet 2012 18:53:44, Joe Lyga a écrit :
</pre>
<blockquote type="cite">
<pre wrap="">I'm new to GDAL, and I'm wondering if there's a way I can get the buffer
of raw compressed image data. I have an NITF file that contains a jpeg
image. I've been able to use the rasterio function to get uncompressed
image data, but what I really need is to just send along that jpeg image
without the NITF wrapping. Is there a funciton to give me just raw
compressed image data? Thanks.
</pre>
</blockquote>
<pre wrap="">
Joe,
No, there's no function to do that. However, you can find some hints with
running gdalinfo with debugging :
$ gdalinfo byte_jpg.ntf --debug on
GDAL: NITFDataset::Open() as IC=C3 (JPEG compressed)
JPG: real_filename byte_jpg.ntf, offset=907, size=519
GDAL: GDALOpen(JPEG_SUBFILE:Q0,907,519,byte_jpg.ntf, this=0x204ce00) succeeds
as JPEG.
GDAL: GDALOpen(byte_jpg.ntf, this=0x204c770) succeeds as NITF.
[...]
This reveals that there is a JPEG stream starting at offset 907 and of length
519 bytes.
Which can be verified with :
$ gdalinfo /vsisubfile/907_519,byte_jpg.ntf -checksum
Driver: JPEG/JPEG JFIF
Files: /vsisubfile/907_519,byte_jpg.ntf
Size is 20, 20
Coordinate System is `'
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 20.0)
Upper Right ( 20.0, 0.0)
Lower Right ( 20.0, 20.0)
Center ( 10.0, 10.0)
Band 1 Block=20x1 Type=Byte, ColorInterp=Gray
Checksum=4743
Image Structure Metadata:
COMPRESSION=JPEG
Then, using the
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/samples/gdal_cp.py">http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/samples/gdal_cp.py</a>
script :
$ python swig/python/samples/gdal_cp.py /vsisubfile/907_519,byte_jpg.ntf
jpeg_stream_extracted.jpg
or more simply if your are on Linux :
$ dd if=byte_jpg.ntf of=jpeg_stream_extracted.jpg skip=907 count=519 bs=1
Then :
$ gdalinfo jpeg_stream_extracted.jpg -checksum
Driver: JPEG/JPEG JFIF
Files: jpeg_stream_extracted.jpg
Size is 20, 20
Coordinate System is `'
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 20.0)
Upper Right ( 20.0, 0.0)
Lower Right ( 20.0, 20.0)
Center ( 10.0, 10.0)
Band 1 Block=20x1 Type=Byte, ColorInterp=Gray
Checksum=4743
Image Structure Metadata:
COMPRESSION=JPEG
The above will work with IC=C3 compressed NITF files. For IC=M3, as you have
several tiles, it will be a bit more complicated.
</pre>
</blockquote>
<br>
<br>
</body>
</html>