Skip to content

Instantly share code, notes, and snippets.

@energizer91
energizer91 / png.js
Created March 1, 2019 10:06
Get diff from 2 PNGs and recreate them
const PNG = require('pngjs').PNG;
const fs = require('fs');
const img1 = fs.createReadStream('./4a.png').pipe(new PNG()).on('parsed', doneReading);
const img2 = fs.createReadStream('./4b.png').pipe(new PNG()).on('parsed', doneReading);
let filesRead = 0;
function applyPixels(data1, data2, width, height, result) {
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const express = require('express');
const app = express();
app.post('/file', (req, res, next) => {
let first = true;
req.on('data', chunk => {
if (!first) {
return;
const express = require('express');
const fs = require('fs');
const path = require('path');
const app = express();
app.post('/file', (req, res) => {
req.pipe(fs.createWriteStream(path.join(__dirname, 'somefile')));
req.on('end', () => {