Pixelate an image, with or without grid.
Example:
"Why something like pixelator", you might ask... "Why not?", is my answer :)
file- (File) The image to pixelate.options- (Object) Optional.boxSize: (Number) The resulting image will consist of boxSize * boxSize squares.gridSize: (Number) The squares in the resulting image will be separated by a distance of gridSizegridColor: (String) RGB hex value e.g.#ff0000. Defaults totransparent.
Promise({ file: File, ?gridFile: File })
file- The pixelated filegridFile- This is only available if a grid value (gridSize) > 0 is given as input in theoptions-object.
let options = {
boxSize: 50 // Size of the sides of the squares, this will result in 50x50 pixel squares.
gridSize: 2, // This will create a 2 pixel wide separation between the boxes. Defaults to 0.
gridColor: '#ff0000' // This sets the grid color to red.
};
pixelator.pixelate(file, options).then(resultObject => {
let pixelatedFile = resultObject.file;
let gridFile = resultObject.gridFile; // If options.gridSize < 1 || !options.gridSize,
}); // this will not be generated