changeDPI provides 2 utility functions that can change the dpi of canvas-generated image, of either dataUrl or Blob formats. The functions work on separating the header from the image data, converting and manipulating just the header, then sticking the header back on the file. In this way, very large images can be converted fast without having to convert the entire contents of an image file. This process is non-destructive—image data does not get modified in the process.
npm install --save changedpi
From a canvas element dataUrl:
// create the dataUrl at standard 72dpivar dataUrl = canvas;var daurl150dpi = ;
From a canvas element blob:
// create the blob at standard 72dpicanvas;
TODO add example with file reader
This module uses ES6. To see a compiled ES5 version, run
npm run build and look in
npm installnpm run test
Please do contribute! Open an issue or submit a pull request.