JPEG encoding w/ JFIF encoding

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Hitachi1961
Posts: 7
Joined: 2017-03-09T15:38:17-07:00
Authentication code: 1151

JPEG encoding w/ JFIF encoding

Post by Hitachi1961 » 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:
  1. Optionally convert the colors in the image from RGB to YCBCR
  2. Optionally reduce the resolution of chroma data by a factor of 2 or 3
  3. Split up the image into blocks of 8x8 pixels and apply DCT-II on each pixel to get DCT coefficients
  4. Quantize DCT coefficients
  5. Compress quantized values using some variant of Huffmans encoding
I feel like I'm trying to "reinvent the wheel" and maybe theres something already built into imagemagick encoding process to help with this. Some of the steps are somewhat still vague to me, (for example the Huffman encoding step) so any clarification would also help. Ideally I would like to be able to perform each of the steps at a high level and have access to the data during each step, for example:

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);
 

User avatar
fmw42
Posts: 20922
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: JPEG encoding w/ JFIF encoding

Post by fmw42 » 2017-03-14T14:49:26-07:00


snibgo
Posts: 8655
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: JPEG encoding w/ JFIF encoding

Post by snibgo » 2017-03-14T14:52:56-07:00

IM does all that work for you. Just write to an output file with extension ".jpg" or ".jpeg".

But it doesn't give you access to data during each step.
snibgo's IM pages: im.snibgo.com

Post Reply

Who is online

Users browsing this forum: rpatelob and 4 guests