How to use the jimp.RESIZE_BICUBIC function in jimp

To help you get started, we’ve selected a few jimp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lovell / sharp / test / bench / perf.js View on Github external
jimp.read(inputJpgBuffer, function (err, image) {
          if (err) {
            throw err;
          } else {
            image
              .resize(width, height, jimp.RESIZE_BICUBIC)
              .quality(80)
              .getBuffer(jimp.MIME_JPEG, function (err) {
                if (err) {
                  throw err;
                } else {
                  deferred.resolve();
                }
              });
          }
        });
      }
github kura52 / sushi-browser / src / captureFaviconEvent.js View on Github external
Jimp.read(imgBuffer, function (err, image) {
              if (err || !image) {
                console.log("ERROR Failed to save file", err);
                resolve(blob)
              }
              if(Math.max(image.bitmap.width,image.bitmap.height) <= 20){
                console.log(146,Date.now())
                resolve(`data:image/png;base64,${imgBuffer.toString('base64')}`)
              }
              else{
                console.log(147,Date.now())
                if(image.bitmap.width > image.bitmap.height){
                  image = image.resize(20,Jimp.AUTO,Jimp.RESIZE_BICUBIC)
                }
                else{
                  image = image.resize(Jimp.AUTO,20,Jimp.RESIZE_BICUBIC)
                }
                image.getBase64(Jimp.AUTO, function (err, src) {
                  resolve(src)
                })
              }
            })
          }).catch(e=>{
github Lorti / resemble-image / src / main.js View on Github external
Jimp.read(path, (err, image) => {
            if (err) {
                reject(err);
            }

            let strip;

            try {
                strip = image.clone().resize(256, 4, Jimp.RESIZE_BICUBIC);
            } catch (e) {
                return reject(e);
            }

            const palette = quant(strip.bitmap.data, {
                netsize: 16,
                samplefac: 10,
            });

            strip.scan(0, 0, strip.bitmap.width, strip.bitmap.height, function (x, y, idx) {
                const colorIndex = findClosest(
                    palette,
                    this.bitmap.data[idx],
                    this.bitmap.data[idx + 1],
                    this.bitmap.data[idx + 2],
                );
github Lorti / resemble-image / src / main.js View on Github external
samplefac: 10,
            });

            strip.scan(0, 0, strip.bitmap.width, strip.bitmap.height, function (x, y, idx) {
                const colorIndex = findClosest(
                    palette,
                    this.bitmap.data[idx],
                    this.bitmap.data[idx + 1],
                    this.bitmap.data[idx + 2],
                );
                this.bitmap.data[idx] = palette[colorIndex * 3];
                this.bitmap.data[idx + 1] = palette[(colorIndex * 3) + 1];
                this.bitmap.data[idx + 2] = palette[(colorIndex * 3) + 2];
            });

            strip.resize(256, 1, Jimp.RESIZE_BICUBIC);

            const groups = [];
            let previous = '#';

            for (let x = 0; x < strip.bitmap.width; x++) {
                const color = rgbToHex(Jimp.intToRGBA(strip.getPixelColor(x, 0)));
                if (color !== previous) {
                    groups.push({
                        color,
                        pixels: [x],
                        weight: 1,
                        center: x / strip.bitmap.width,
                    });
                } else {
                    const group = groups[groups.length - 1];
                    group.pixels.push(x);
github kura52 / sushi-browser / src / chromeManifestModify.js View on Github external
Jimp.read(img.toPng(), function (err, image) {
            if(image.bitmap.width > image.bitmap.height){
              image = image.resize(16,Jimp.AUTO,Jimp.RESIZE_BICUBIC)
            }
            else{
              image = image.resize(Jimp.AUTO,16,Jimp.RESIZE_BICUBIC)
            }
            image.write(out)
          })
        }
github heremaps / harp.gl / @here / harp-atlas-tools / src / ImageBitmapCoders.ts View on Github external
resize(width: number, height: number): ImageEncoder {
        return new ImageBitmapEncoder(
            this.m_image.clone().resize(width, height, Jimp.RESIZE_BICUBIC)
        );
    }
github odrick / free-tex-packer-core / utils / TextureRenderer.js View on Github external
new Jimp(width, height, 0x0, (err, image) => {
            this.buffer = image;

            for(let item of data) {
                this.renderItem(item, options);
            }
            
            let filter = new options.filter();
            filter.apply(image);

            if(options.scale && options.scale !== 1) {
                let scaleMethod = Jimp.RESIZE_BILINEAR;

                if(options.scaleMethod === "NEAREST_NEIGHBOR") scaleMethod = Jimp.RESIZE_NEAREST_NEIGHBOR;
                if(options.scaleMethod === "BICUBIC") scaleMethod = Jimp.RESIZE_BICUBIC;
                if(options.scaleMethod === "HERMITE") scaleMethod = Jimp.RESIZE_HERMITE;
                if(options.scaleMethod === "BEZIER") scaleMethod = Jimp.RESIZE_BEZIER;

                image.resize(Math.round(width * options.scale) || 1, Math.round(height * options.scale) || 1, scaleMethod);
            }

            if(this.callback) this.callback(this);
        });
    }
github steambap / png-to-ico / index.js View on Github external
.then(image => {
			const bitmap = image.bitmap;
			const size = bitmap.width;
			if (image._originalMime !== Jimp.MIME_PNG || size !== bitmap.height) {
				throw err;
			}
			if (size !== 256) {
				image.resize(256, 256, Jimp.RESIZE_BICUBIC);
			}

			const resizedImages = sizeList.map(targetSize =>
				image.clone().resize(targetSize, targetSize, Jimp.RESIZE_BICUBIC)
			);

			return Promise.all(resizedImages.concat(image));
		})
		.then(imagesToIco);
github jbeuckm / strapi-plugin-image-formats / admin / src / jimpMethodConfigs / resize.js View on Github external
const Jimp = require('jimp');

const RESIZE_MODES = [
  Jimp.RESIZE_NEAREST_NEIGHBOR,
  Jimp.RESIZE_BILINEAR,
  Jimp.RESIZE_BICUBIC,
  Jimp.RESIZE_HERMITE,
  Jimp.RESIZE_BEZIER
];

const FIELD_CONFIGS = {
  width: {
    type: 'integer',
    min: 1,
    max: 4096,
    required: true,
    default: 150
  },
  height: {
    type: 'integer',
    min: 1,
    max: 4096,
github ben-eb / postcss-resemble-image / src / resembleImage.js View on Github external
let width;
            let height;
            let chunk;
            try {
                width = image.bitmap.width;
                height = image.bitmap.height;
                chunk = resolveFidelity(width, fidelity);
            } catch (e) {
                return reject(e);
            }
            const stops = [];
            const colourStop = colourStopFactory(width);
            for (let i = 0; i < width; i += chunk) {
                let color = image.clone()
                    .crop(i, 0, chunk, height)
                    .resize(1, 1, Jimp.RESIZE_BICUBIC)
                    .getPixelColor(0, 0);
                color = rgbToHex(Jimp.intToRGBA(color));
                stops.push(colourStop(color, i));
            }
            return resolve(generator(stops));
        });
    });