Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var goalResolution = options.goalResolution;
var jimpAO = options.jimpAO;
// Copy the data over to the jimp
jimpAO.resize(dataResolution, dataResolution);
for (var x = 0; x < dataResolution; x++) {
for (var y = 0; y < dataResolution; y++) {
var dataIdx = dataResolution * y + x;
var sampleCount = aoBuffer.count[dataIdx];
var value = 0.0;
value = 255.0 * (aoBuffer.samples[dataIdx] / sampleCount);
jimpAO.bitmap.data[dataIdx * 4 + 3] = value;
}
}
// Resize the data to match the goal resolution
jimpAO.resize(goalResolution, goalResolution, Jimp.RESIZE_BEZIER);
}
function enhanceImage(image, scaleFactor) {
image.scale(scaleFactor, Jimp.RESIZE_BEZIER);
image.invert();
image.greyscale();
/*
image.convolute([
[0, 0, 0, 0, 0],
[0, 0, -1, 0, 0],
[0, -1, 5, -1, 0],
[0, 0, -1, 0, 0],
[0, 0, 0, 0, 0]
]);
*/
image.convolute([
[-1 / 8, -1 / 8, -1 / 8],
[-1 / 8, 2, -1 / 8],
[-1 / 8, -1 / 8, -1 / 8]
]);
Jimp.read(image, (err, img) => {
if (err) {
return reject(err)
}
let fmt = opts.format === 'png' ? Jimp.MIME_PNG : Jimp.MIME_JPEG
let quality = 100
if (opts.quality) {
quality = opts.quality
}
img.scale(1.0 / screen.devicePixelRatio, Jimp.RESIZE_BEZIER)
.quality(quality)
.getBuffer(fmt, (err, buffer) => {
if (err) {
reject(err)
} else {
resolve(buffer)
}
})
})
})
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,
required: true,
default: 150
.then(file => {
file.resize(dim.center, Jimp.AUTO, Jimp.RESIZE_BEZIER)
.background(0xFFFFFFFF)
.contain(dim.w, dim.center,
Jimp.HORIZONTAL_ALIGN_CENTER | Jimp.VERTICAL_ALIGN_MIDDLE)
.contain(dim.w, dim.h,
Jimp.HORIZONTAL_ALIGN_CENTER | Jimp.VERTICAL_ALIGN_MIDDLE)
.write(path.join('./public/img/',
'apple-touch-startup-image-' + dim.w + 'x' + dim.h + '.png'));
});
}))
.then(file => {
file.resize(icon.size, Jimp.AUTO, Jimp.RESIZE_BEZIER)
.write(path.join('./public/img/', icon.name));
});
}))
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);
});
}
.then(function() {
var pipelineExtras0001 = gltfClone.images.Image0001.extras._pipeline;
var jimpImage001 = pipelineExtras0001.jimpImage;
jimpImage001.resize(10, 10, Jimp.RESIZE_BEZIER);
pipelineExtras0001.imageChanged = true;
var pipelineExtras0002 = gltfClone.images.Image0002.extras._pipeline;
var jimpImage002 = pipelineExtras0002.jimpImage;
pipelineExtras0002.imageChanged = true;
encodeImages(gltfClone)
.then(function() {
expect(jimpImage001.bitmap.width).toEqual(10);
expect(jimpImage001.bitmap.height).toEqual(10);
expect(jimpImage002.bitmap.width).toEqual(8);
expect(jimpImage002.bitmap.height).toEqual(8);
expect(pipelineExtras0001.source.equals(imageBuffer)).not.toBe(true);
expect(pipelineExtras0002.source.equals(imageBuffer)).not.toBe(true);