JPEG encoding w/ JFIF encoding
Posted: 2017-03-14T14:21:26-07:00
OS/Platform: OSX 10.12.3
IM Version: stable 7.0.5-0
Does imagemagick implement/provide an api or any helpers to use standard JFIF encoding when compressing/encoding a JPEG image? Based on this wikipedia article my understanding of the steps involved are the following:
IM Version: stable 7.0.5-0
Does imagemagick implement/provide an api or any helpers to use standard JFIF encoding when compressing/encoding a JPEG image? Based on this wikipedia article my understanding of the steps involved are the following:
- Optionally convert the colors in the image from RGB to YCBCR
- Optionally reduce the resolution of chroma data by a factor of 2 or 3
- Split up the image into blocks of 8x8 pixels and apply DCT-II on each pixel to get DCT coefficients
- Quantize DCT coefficients
- Compress quantized values using some variant of Huffmans encoding
Code: Select all
ycbcr_values[] = imagetorcbcr('my image.jpeg');
ycbcr_values[] = reducechroma(ycbcr_values, 3);
blocks[][] = pixelstoblocks(ycbcr_values, 8, 8);
dct_blocks[][] = dct(blocks);
quantized_blocks[][] = quantize(dct_blocks);
image = writeimage('out image.jpeg', quantized_blocks);