[gdal-dev] reading compressed data?
Joe Lyga
joe.lyga at vcoresolutions.com
Tue Jul 10 11:51:14 PDT 2012
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.
Joe Lyga
Software Engineer
Balfour Technologies LLC and VCORE Solutions LLC
Morrelly Homeland Security Center
510 Grumman Road West, Suite 212, Bethpage NY 11714
Phone: (516) 513-0030
/"Innovations in Mission Critical Visualization with fourDscape®"/
On 7/10/2012 1:45 PM, Even Rouault wrote:
> Le mardi 10 juillet 2012 18:53:44, Joe Lyga a écrit :
>> 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.
> 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
> http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/samples/gdal_cp.py
> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120710/460f3258/attachment-0001.html>
More information about the gdal-dev
mailing list