ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: StarGeek on July 23, 2018, 07:29:13 PM

Title: Detect Jpeg Minimum Coded Unit (MCU) size
Post by: StarGeek on July 23, 2018, 07:29:13 PM
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? 
Title: Re: Detect Jpeg Minimum Coded Unit (MCU) size
Post by: StarGeek on July 23, 2018, 07:45:26 PM
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. 

Title: Re: Detect Jpeg Minimum Coded Unit (MCU) size
Post by: Phil Harvey on July 23, 2018, 09:44:42 PM
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
Title: Re: Detect Jpeg Minimum Coded Unit (MCU) size
Post by: StarGeek on July 24, 2018, 03:51:16 PM
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 (https://en.wikipedia.org/wiki/JPEG#Lossless_editing) 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.