Reading quantization table of JPEG

Hi All,

is there some easy way, how to read coefficients of quantization table from a jpeg file? I have been looking at GitHub - JuliaIO/JpegTurbo.jl: Julia interface to libjpeg-turbo, but I have not found a relevant calls exported from a C.

I have used Get DCT coefficients of jpeg image to obtain the DCT coefficients, but I also need to read quantization coefficients.

Any help will be greatly appreciated.

Tomas

Seems like I can read it from a jpeg head as

using JpegTurbo
import JpegTurbo: LibJpeg
import JpegTurbo.LibJpeg: DCTSIZE

    CT = JpegTurbo._default_out_color_space(data)
    out_CT, jpeg_cls = JpegTurbo._jpeg_out_color_space(CT)
    cinfo_ref = Ref(LibJpeg.jpeg_decompress_struct())
    jerr = Ref{LibJpeg.jpeg_error_mgr}()
    cinfo = cinfo_ref[]
    cinfo.err = LibJpeg.jpeg_std_error(jerr)
    LibJpeg.jpeg_create_decompress(cinfo_ref)
    LibJpeg.jpeg_mem_src(cinfo_ref, data, length(data))
    LibJpeg.jpeg_read_header(cinfo_ref, true)

   unsafe_load(cinfo.quant_tbl_ptrs[1])

where data contains the raw bytes read from jpeg file as open(read, "image.jpg",'r')

2 Likes