Detect Jpeg Minimum Coded Unit (MCU) size

Started by StarGeek, July 23, 2018, 07:29:13 PM

Previous topic - Next topic

StarGeek

I'm playing around with making a script that will using ImageMagick and JpegTran to do a lossless autocrop of solid color borders.  And while I could play it safe and assume that the block sizes are 16x16, I'd like it to be more accurate when possible.

So my question is, can the MCU size be determined from exiftool output?  Is the YCbCrSubSampling tag the data I should be looking at? 
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

Actually, it turns out the question is moot.  Jpegtran will move the top/left boundary outward to the nearest block edge, while holding the bottom/right edge in place.  I didn't expect that.

But now, I'm still interested in the answer to the above question. 

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

I have no idea.  I doubt that YCbCrSubSampling is what you need, but I don't ever remember seeing metadata for "Minimum Coded Unit".  "Micro Controller Unit" yes, but no other MCU that I remember.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

No worries.

It's not so much metadata as a property of the jpeg file, like EncodingProcess or BitsPerSample.  It's the size of blocks of pixels used in the encoding.

For all my searching around the web, it turns out I missed the line on Wikipedia where it says that 4:2:0 chroma subsampling is the 16x16 block size.  That gives me a starting point if I decide I want to test things further.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).