Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const gl = createGLContext(WIDTH_S, HEIGHT_S)
if (!gl) {
console.error('Unable to create GL context')
process.exit(1)
}
const blendData = JSON.parse(result.result[0])
const timePiece = time(blendData, gl)
const gif = new GifEncoder(WIDTH, HEIGHT, {highWaterMark: 1024 * 1024})
gif.pipe(fs.createWriteStream(outPath))
gif.setRepeat(0)
gif.writeHeader()
sharp.cache(false) // Reduce memory usage
const totalFrames = 2 * FRAMES - 1
for (let i = 0; i < totalFrames; i++) {
// Render frame
const y = i < FRAMES ? i / FRAMES : 2 - i / FRAMES
timePiece.renderFrame(.5, y)
// Get frame data
let pixels = new Uint8Array(WIDTH_S * HEIGHT_S * 4)
gl.readPixels(0, 0, WIDTH_S, HEIGHT_S, gl.RGBA, gl.UNSIGNED_BYTE, pixels)
// Resize and flip (otherwise gifs come out upside-down!?)
let framePixels = await sharp(Buffer.from(pixels.buffer), {
raw: {
width: WIDTH_S,
height: HEIGHT_S,
const assert = require('assert');
const async = require('async');
const sharp = require('sharp');
const path = require('path');
const {sharpToString, imgToProcessedPng} = require('../specs/processing.js');
if (process.env.DISABLE_SHARP_CACHE)
sharp.cache(false);
// Typical cover resize for people portraits
const COVER_RESIZE = {
width: 300 * 2,
height: 225 * 2
};
exports.buildCover = function buildCover(
inputDir,
outputDir,
pathPrefix,
item,
options,
callback
) {
assert(!!item.cover, `wilson/images.buildCover: cannot build cover if item "${item.id}" has none.`);
export async function getImageDimensionsWithSharpAsync(dirname: string, filename: string) {
const filepath = path.join(dirname, filename);
// PLEASE DON'T REMOVE THE FOLLOWING LINE (sharp caches files taking path as the cache key)
sharp.cache(false);
try {
const { width, height } = await sharp(filepath).metadata();
return { width, height };
} catch (e) {
return null;
}
}
var sharp = require('sharp');
var config = require('./config');
var FORMATS = config.FORMATS;
var MIN_WIDTH = config.MIN_WIDTH;
var MIN_HEIGHT = config.MIN_HEIGHT;
// Sharp seems to cache files based on their
// path and not the contents of the file at
// a particular path. It was returning stale
// versions of a file in the blog's folder.
// Perhaps it might be smarter to copy the file
// to the temporary directory before operating on it?
// It's also possible that this is a bug in Sharp's
// caching that has been fixed in a more recent version
// or that still needs to be fixed. I should investigate.
sharp.cache(false);
module.exports = function (path, callback) {
var image = sharp(path);
image.metadata(function(err, info){
if (err) return callback(err);
if (!info) return callback(new Error('Could not read file info'));
var format = info.format.toLowerCase();
var width = info.width;
var height = info.height;
if (FORMATS.indexOf(format) === -1)
export async function resizeIconWithSharpAsync(iconSizePx: number, iconFilename: string, destinationIconPath: string) {
const filename = path.join(destinationIconPath, iconFilename);
// PLEASE DON'T REMOVE THE FOLLOWING LINE (sharp caches files taking path as the cache key)
sharp.cache(false);
// sharp can't have same input and output filename, so load to buffer then
// write to disk after resize is complete
const buffer = await sharp(filename)
.resize(iconSizePx, iconSizePx)
.toBuffer();
await fs.writeFile(filename, buffer);
}
const express = require('express')
const {
lstatSync,
readFileSync,
readdirSync,
existsSync,
mkdirSync,
writeFile,
unlinkSync
} = require('fs')
const {
join
} = require('path')
const rimraf = require('rimraf')
const sharp = require('sharp')
sharp.cache(false)
const multer = require("multer")
const userRoutes = express.Router()
//folders
const rootFolder = join(__dirname, '../../')
const dataFolder = join(rootFolder, 'data')
const usersFolder = join(dataFolder, 'users')
const storage = multer.diskStorage({
destination: function(req, file, callback) {
callback(null, usersFolder)
},
filename: function(req, file, callback) {
let fileComponents = file.originalname.split(".")
let fileExtension = fileComponents[fileComponents.length - 1]
let filename = `${file.originalname}_${Date.now()}.${fileExtension}`
"use strict";
/**
* Contains classes and functions to process images.
*
* @module
*/
var sharp = require("sharp");
var temp = require("temp");
var U = require("glacejs-utils");
sharp.cache(false);
/**
* Creates new instance of Image.
*
* @class
* @arg {string} srcPath - path to processed image
* @arg {object} [srcOpts] - image options
* @arg {number} [srcOpts.scaleX] - image current scale value on `X` axis
* @arg {number} [srcOpts.scaleY] - image current scale value on `Y` axis
*/
var Image = module.exports = function (srcPath, srcOpts) {
if (!(this instanceof Image))
return new Image(srcPath, srcOpts);
srcOpts = U.defVal(srcOpts, {});
srcOpts.scaleX = U.defVal(srcOpts.scaleX, 1);
*
* @module
*/
var fs = require("fs");
var path = require("path");
var _ = require("lodash");
var imageDiff = require("image-diff");
var sharp = require("sharp");
var uuid = require("uuid/v4");
var U = require("glacejs-utils");
var image = require("../image");
sharp.cache(false);
/**
* Steps to manage web screenshots and images.
*
* @mixin ImageSteps
*/
module.exports = {
/**
* Step to make web screenshot in browser.
*
* @async
* @method
* @instance
* @arg {object} [opts] - Step options.
* @arg {string} [opts.imageName] - Screenshot name. File extension
* `.png` will be added automatically. Default value is dynamically
* generated on each call with algorithm `uuid`.
constructor(inputNode, options) {
super([inputNode], {
annotation: 'build-ilios-icons'
});
sharp.cache(false);
this.options = options;
}
constructor(inputNode, options) {
super([inputNode], {
annotation: 'ember-cli-image-transformer-build'
});
sharp.cache(false);
this.options = options;
}