# Reading quantization table of JPEG

**URL:** <https://discourse.julialang.org/t/reading-quantization-table-of-jpeg/97315>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 10, 2023, 7:01pm UTC](https://discourse.julialang.org/t/reading-quantization-table-of-jpeg/97315 "2023-04-10T19:01:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [April 10, 2023, 7:01pm UTC](https://discourse.julialang.org/t/reading-quantization-table-of-jpeg/97315/1 "2023-04-10T19:01:10Z")

</div>

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](https://github.com/JuliaIO/JpegTurbo.jl), but I have not found a relevant calls exported from a C.

I have used [Get DCT coefficients of jpeg image](https://discourse.julialang.org/t/get-dct-coefficients-of-jpeg-image/64640) to obtain the DCT coefficients, but I also need to read quantization coefficients.

Any help will be greatly appreciated.

Tomas

---

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [April 10, 2023, 7:17pm UTC](https://discourse.julialang.org/t/reading-quantization-table-of-jpeg/97315/2 "2023-04-10T19:17:15Z")

</div>

Seems like I can read it from a jpeg head as

```julia
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')`
