Skip to content

Instantly share code, notes, and snippets.

Avatar
🙂
Hello World !

Franck Freiburger FranckFreiburger

🙂
Hello World !
View GitHub Profile
@FranckFreiburger
FranckFreiburger / duplexify.mjs
Last active Aug 27, 2020
nodejs readable and writable stream to duplex stream
View duplexify.mjs
import { Duplex } from 'stream'
export default class Duplexify extends Duplex {
constructor(writable, readable) {
super({
readableObjectMode: readable.readableObjectMode,
writableObjectMode: writable.writableObjectMode,
readableHighWaterMark: readable.readableHighWaterMark,
@FranckFreiburger
FranckFreiburger / getJpegQuality.js
Created Oct 4, 2018
pure JavaScript jpeg quality value recover
View getJpegQuality.js
// javascript jpeg decoder: https://github.com/eugeneware/jpeg-js/blob/79c4c7ea876d2e7b46981a563fcc4ae8f9e19849/lib/decoder.js
// Determine the JPEG compression quality from the quantization tables: https://github.com/ImageMagick/ImageMagick/blob/59f28acff016f6ae5e8b7e6300bcdf97e94affc9/coders/jpeg.c#L879
// JPEG File Layout and Format: http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm
// jpeg constants: https://github.com/LuaDist/libjpeg/blob/6c0fcb8ddee365e7abc4d332662b06900612e923/jpeglib.h#L45
function getQuantizationTables(data) {
var quantizationTables = []
var dctZigZag = new Int32Array([