Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function configureJimp() {
return configure({
types: [
() => ({
mime: { 'image/png': ['png'] },
constants: {
MIME_PNG: 'image/png'
},
hasAlpha: { 'image/png': true },
decoders: { 'image/png': PNG.sync.read },
encoders: {
'image/png': data => {
const png = new PNG({
width: data.bitmap.width,
height: data.bitmap.height,
bitDepth: 8,
function loadConfiguration(
plugins: string[],
types: string[],
verbose: boolean
) {
if (!plugins.length && !types.length) {
return;
}
log(` 🔄 Loading custom types/plugins into Jimp...`, verbose);
const loadedPlugins = load('plugin', plugins, verbose);
const loadedTypes = load('type', types, verbose);
custom({ types: loadedTypes, plugins: loadedPlugins }, Jimp);
}
import {
ImageOptions,
ImageData,
ImageSource,
ImageCallback,
ImageBase
} from '@vibrant/image'
import * as http from 'http'
import * as https from 'https'
import configure from '@jimp/custom'
import types from '@jimp/types'
import resize from '@jimp/plugin-resize'
const Jimp = configure({
types: [types],
plugins: [resize]
})
interface ProtocalHandler {
get (url: string | any, cb?: (res: any) => void): any
}
interface ProtocalHandlerMap {
[protocolName: string]: ProtocalHandler
}
const URL_REGEX: RegExp = /^(\w+):\/\/.*/i
const PROTOCOL_HANDLERS: ProtocalHandlerMap = {
http,