Skip to content

Commit

Permalink
Filter downsampled pixel art (itgalaxy#257)
Browse files Browse the repository at this point in the history
* Created a more intricate sample image for pixel art, which is downsampled by a few favicons.

* Nearest-neighbour is now only used when upscaling pixel art; this preserves the impression of detail when generating small favicons from large sprites.
  • Loading branch information
jameswilddev authored and brunocodutra committed Feb 16, 2019
1 parent 7cb1a37 commit ed95ccc
Show file tree
Hide file tree
Showing 4 changed files with 6,073 additions and 4,363 deletions.
6 changes: 5 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,11 @@ module.exports = function(options) {
width,
height,
Jimp.HORIZONTAL_ALIGN_CENTER | Jimp.VERTICAL_ALIGN_MIDDLE,
options.pixel_art ? Jimp.RESIZE_NEAREST_NEIGHBOR : null
options.pixel_art &&
width >= image.bitmap.width &&
height >= image.bitmap.height
? Jimp.RESIZE_NEAREST_NEIGHBOR
: null
)
);
}
Expand Down
Binary file modified test/fixtures/pixel_art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ed95ccc

Please sign in to comment.