Napoleon's Pixelated Mugshot

    changedpi

    1.0.4 • Public • Published

    changeDPI

    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.

    Install

    This project depends on node and npm.

    npm install --save changedpi

    Usage

    From a canvas element dataUrl:

    // create the dataUrl at standard 72dpi
    var dataUrl = canvas.toDataURL('image/jpeg', 0.92);
    var daurl150dpi = changeDpiDataUrl(dataUrl, 150);

    From a canvas element blob:

    // create the blob at standard 72dpi
    canvas.toBlob(function(blob) {
      changeDpiBlob(blob, 300).then(function(blob){
        // use your changed blob
      })
    },'image/jpeg', 0.92);
      TODO add example with file reader.

    ES6

    This module uses ES6. To see a compiled ES5 version, run npm run build and look in dist/.

    Testing

    npm install .
    npm run test

    Contribute

    Please do contribute! Open an issue or submit a pull request.

    The project falls under @Shutterstock's Code of Conduct.

    License

    MIT.

    Install

    npm i changedpi

    DownloadsWeekly Downloads

    3,288

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    21.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • sstk-admin