function jpegQuality(buffer) {

	const data = new Uint8Array(buffer);
	const tables = getQuantizationTables(data);

	if (!tables.length) {
		throw new Error('Missing quantization tables');
	}

	let hash, hashMap;
	let sum, sumMap;

	if (tables.length < 2) {
		sum = tables[0].values.reduce((a, b) => a + b);
		sumMap = sumMaps[0];
		hash = tables[0].values[2] + tables[0].values[53];
		hashMap = hashMaps[0];
	}
	else {
		sum = tables[0].values.reduce((a, b) => a + b) + tables[1].values.reduce((a, b) => a + b);
		sumMap = sumMaps[1];
		hash = tables[0].values[2] + tables[0].values[53] + tables[1].values[0] + tables[1].values[63];
		hashMap = hashMaps[1];
	}

	return Math.min(
		getInterpolatedFromMap(hash, hashMap),
		getInterpolatedFromMap(sum, sumMap)
	);

}
/**
 * Get the estimated JPEG quality of an image between 0 and 100
 *
 * @param  {ArrayBuffer} buffer
 * @return number
 */
Get the estimated JPEG quality of an image between 0 and 100
@param  {ArrayBuffer} buffer
@return number
Get the estimated JPEG quality of an image between 0 and 100 @param { ArrayBuffer } buffer @return number
function jpegQuality(buffer) {
	const data = new Uint8Array(buffer);
	const tables = getQuantizationTables(data);
	if (!tables.length) {
		throw new Error('Missing quantization tables');
	}
	let hash, hashMap;
	let sum, sumMap;
	if (tables.length < 2) {
		sum = tables[0].values.reduce((a, b) => a + b);
		sumMap = sumMaps[0];
		hash = tables[0].values[2] + tables[0].values[53];
		hashMap = hashMaps[0];
	}
	else {
		sum = tables[0].values.reduce((a, b) => a + b) + tables[1].values.reduce((a, b) => a + b);
		sumMap = sumMaps[1];
		hash = tables[0].values[2] + tables[0].values[53] + tables[1].values[0] + tables[1].values[63];
		hashMap = hashMaps[1];
	}
	return Math.min(
		getInterpolatedFromMap(hash, hashMap),
		getInterpolatedFromMap(sum, sumMap)
	);
}
function jpegQuality ( buffer ) { const data = new Uint8Array ( buffer ) ; const tables = getQuantizationTables ( data ) ; if ( ! tables . length ) { throw new Error ( 'Missing quantization tables' ) ; } let hash , hashMap ; let sum , sumMap ; if ( tables . length < 2 ) { sum = tables [ 0 ] . values . reduce ( ( a , b ) => a + b ) ; sumMap = sumMaps [ 0 ] ; hash = tables [ 0 ] . values [ 2 ] + tables [ 0 ] . values [ 53 ] ; hashMap = hashMaps [ 0 ] ; } else { sum = tables [ 0 ] . values . reduce ( ( a , b ) => a + b ) + tables [ 1 ] . values . reduce ( ( a , b ) => a + b ) ; sumMap = sumMaps [ 1 ] ; hash = tables [ 0 ] . values [ 2 ] + tables [ 0 ] . values [ 53 ] + tables [ 1 ] . values [ 0 ] + tables [ 1 ] . values [ 63 ] ; hashMap = hashMaps [ 1 ] ; } return Math . min ( getInterpolatedFromMap ( hash , hashMap ) , getInterpolatedFromMap ( sum , sumMap ) ) ; }
Get the estimated JPEG quality of an image between 0 and 100
 @param  {ArrayBuffer} buffer
 @return number
Get the estimated JPEG quality of an image between 0 and 100 @param { ArrayBuffer } buffer @return number