New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imagetools-core

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagetools-core - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

2

dist/builtins.d.ts

@@ -1,1 +0,1 @@

export declare const builtins: (import("./types").TransformFactory<import("./transforms/blur").BlurOptions> | import("./types").TransformFactory<import("./transforms/flatten").FlattenOptions> | import("./types").TransformFactory<import("./transforms/flip").FlipOptions> | import("./types").TransformFactory<import("./transforms/flop").FlopOptions> | import("./types").TransformFactory<import("./transforms/format").FormatOptions> | import("./types").TransformFactory<import("./transforms/grayscale").GrayscaleOptions> | import("./types").TransformFactory<import("./transforms/hsb").HSBOptions> | import("./types").TransformFactory<import("./transforms/invert").InvertOptions> | import("./types").TransformFactory<import("./transforms/median").MedianOptions> | import("./types").TransformFactory<import("./transforms/normalize").NormalizeOptions> | import("./types").TransformFactory<import("./transforms/resize").ResizeOptions> | import("./types").TransformFactory<import("./transforms/rotate").RotateOptions> | import("./types").TransformFactory<import("./transforms/tint").TintOptions>)[];
export declare const builtins: (import("./types.js").TransformFactory<import("./transforms/blur.js").BlurOptions> | import("./types.js").TransformFactory<import("./transforms/flatten.js").FlattenOptions> | import("./types.js").TransformFactory<import("./transforms/flip.js").FlipOptions> | import("./types.js").TransformFactory<import("./transforms/flop.js").FlopOptions> | import("./types.js").TransformFactory<import("./transforms/format.js").FormatOptions> | import("./types.js").TransformFactory<import("./transforms/grayscale.js").GrayscaleOptions> | import("./types.js").TransformFactory<import("./transforms/hsb.js").HSBOptions> | import("./types.js").TransformFactory<import("./transforms/invert.js").InvertOptions> | import("./types.js").TransformFactory<import("./transforms/median.js").MedianOptions> | import("./types.js").TransformFactory<import("./transforms/normalize.js").NormalizeOptions> | import("./types.js").TransformFactory<import("./transforms/resize.js").ResizeOptions> | import("./types.js").TransformFactory<import("./transforms/rotate.js").RotateOptions> | import("./types.js").TransformFactory<import("./transforms/tint.js").TintOptions>)[];

@@ -1,28 +0,28 @@

export * from './transforms/background';
export * from './transforms/blur';
export * from './transforms/fit';
export * from './transforms/flatten';
export * from './transforms/flip';
export * from './transforms/flop';
export * from './transforms/format';
export * from './transforms/grayscale';
export * from './transforms/hsb';
export * from './transforms/invert';
export * from './transforms/kernel';
export * from './transforms/median';
export * from './transforms/normalize';
export * from './transforms/position';
export * from './transforms/progressive';
export * from './transforms/quality';
export * from './transforms/resize';
export * from './transforms/rotate';
export * from './transforms/tint';
export * from './types';
export * from './builtins';
export * from './output-formats';
export * from './util';
export { parseURL, extractEntries } from './lib/parse-url';
export { resolveConfigs } from './lib/resolve-configs';
export { generateTransforms } from './lib/generate-transforms';
export { applyTransforms } from './lib/apply-transforms';
export { getMetadata, setMetadata } from './lib/metadata';
export * from './transforms/background.js';
export * from './transforms/blur.js';
export * from './transforms/fit.js';
export * from './transforms/flatten.js';
export * from './transforms/flip.js';
export * from './transforms/flop.js';
export * from './transforms/format.js';
export * from './transforms/grayscale.js';
export * from './transforms/hsb.js';
export * from './transforms/invert.js';
export * from './transforms/kernel.js';
export * from './transforms/median.js';
export * from './transforms/normalize.js';
export * from './transforms/position.js';
export * from './transforms/progressive.js';
export * from './transforms/quality.js';
export * from './transforms/resize.js';
export * from './transforms/rotate.js';
export * from './transforms/tint.js';
export * from './types.js';
export * from './builtins.js';
export * from './output-formats.js';
export * from './util.js';
export { parseURL, extractEntries } from './lib/parse-url.js';
export { resolveConfigs } from './lib/resolve-configs.js';
export { generateTransforms } from './lib/generate-transforms.js';
export { applyTransforms } from './lib/apply-transforms.js';
export { getMetadata, setMetadata } from './lib/metadata.js';

@@ -251,2 +251,3 @@ import sharp from 'sharp';

return function resizeTransform(image) {
const fit = getFit(config, image);
// calculate finalWidth & finalHeight

@@ -268,9 +269,33 @@ const originalWidth = getMetadata(image, 'width');

}
else if (width && height) {
// width & height BOTH given, need to look at fit
switch (fit) {
case 'inside':
if (width / height < originalAspect) {
finalHeight = width / originalAspect;
}
else {
finalWidth = height * originalAspect;
}
break;
case 'outside':
if (width / height > originalAspect) {
finalHeight = width / originalAspect;
}
else {
finalWidth = height * originalAspect;
}
break;
}
finalAspect = finalWidth / finalHeight;
}
else if (!height) {
// only width was provided, need to calculate height
finalHeight = width / (aspect || originalAspect);
finalAspect = aspect || originalAspect;
finalHeight = width / finalAspect;
}
else if (!width) {
/* only height was provided, need to calculate width */
finalWidth = height * (aspect || originalAspect);
// only height was provided, need to calculate width
finalAspect = aspect || originalAspect;
finalWidth = height * finalAspect;
}

@@ -285,2 +310,4 @@ if (!allowUpscale && (finalHeight > originalHeight || finalWidth > originalWidth)) {

}
finalWidth = Math.round(finalWidth);
finalHeight = Math.round(finalHeight);
setMetadata(image, 'height', finalHeight);

@@ -291,6 +318,6 @@ setMetadata(image, 'width', finalWidth);

return image.resize({
width: Math.round(finalWidth) || undefined,
height: Math.round(finalHeight) || undefined,
width: finalWidth || undefined,
height: finalHeight || undefined,
withoutEnlargement: !allowUpscale,
fit: getFit(config, image),
fit,
position: getPosition(config, image),

@@ -297,0 +324,0 @@ kernel: getKernel(config, image),

import { Sharp } from 'sharp';
import { ImageTransformation, TransformResult } from '../types';
import { ImageTransformation, TransformResult } from '../types.js';
export declare function applyTransforms(transforms: ImageTransformation[], image: Sharp, removeMetadata?: boolean): Promise<TransformResult>;

@@ -1,2 +0,2 @@

import { ImageTransformation, ImageConfig, TransformFactory, Logger } from '../types';
import { ImageTransformation, ImageConfig, TransformFactory, Logger } from '../types.js';
export declare function generateTransforms(config: ImageConfig, factories: TransformFactory[], manualSearchParams: URLSearchParams, logger?: Logger): {

@@ -3,0 +3,0 @@ transforms: ImageTransformation[];

@@ -1,2 +0,2 @@

import { Logger } from '../types';
import { Logger } from '../types.js';
export declare const consoleLogger: Logger;

@@ -1,2 +0,2 @@

import { OutputFormat } from '..';
import { OutputFormat } from '../index.js';
/**

@@ -3,0 +3,0 @@ * This function calculates the cartesian product of two or more arrays and is straight from stackoverflow ;)

@@ -1,2 +0,2 @@

import type { OutputFormat } from './types';
import type { OutputFormat } from './types.js';
export declare const urlFormat: OutputFormat;

@@ -3,0 +3,0 @@ export declare const srcsetFormat: OutputFormat;

@@ -1,2 +0,2 @@

import { TransformOption } from '../types';
import { TransformOption } from '../types.js';
export interface BackgroundOptions {

@@ -3,0 +3,0 @@ background: string;

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface BlurOptions {

@@ -3,0 +3,0 @@ blur: string;

@@ -1,2 +0,2 @@

import { TransformOption } from '../types';
import { TransformOption } from '../types.js';
export declare const fitValues: readonly ["cover", "contain", "fill", "inside", "outside"];

@@ -3,0 +3,0 @@ export type FitValue = (typeof fitValues)[number];

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface FlattenOptions {

@@ -3,0 +3,0 @@ flatten: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface FlipOptions {

@@ -3,0 +3,0 @@ flip: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface FlopOptions {

@@ -3,0 +3,0 @@ flop: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export declare const formatValues: readonly ["avif", "jpg", "jpeg", "png", "heif", "heic", "webp", "tiff"];

@@ -3,0 +3,0 @@ export type FormatValue = (typeof formatValues)[number];

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface GrayscaleOptions {

@@ -3,0 +3,0 @@ grayscale: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface HSBOptions {

@@ -3,0 +3,0 @@ hue: string;

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface InvertOptions {

@@ -3,0 +3,0 @@ invert: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformOption } from '../types';
import { TransformOption } from '../types.js';
export declare const kernelValues: readonly ["nearest", "cubic", "mitchell", "lanczos2", "lanczos3"];

@@ -3,0 +3,0 @@ export type KernelValue = (typeof kernelValues)[number];

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface MedianOptions {

@@ -3,0 +3,0 @@ median: string;

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface NormalizeOptions {

@@ -3,0 +3,0 @@ normalize: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformOption } from '../types';
import { TransformOption } from '../types.js';
export declare const positionValues: readonly ["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest", "center", "centre", "entropy", "attention"];

@@ -3,0 +3,0 @@ export declare const positionShorthands: string[];

@@ -1,2 +0,2 @@

import { TransformOption } from '../types';
import { TransformOption } from '../types.js';
export interface ProgressiveOptions {

@@ -3,0 +3,0 @@ progressive: '' | 'true';

@@ -1,2 +0,2 @@

import { TransformOption } from '../types';
import { TransformOption } from '../types.js';
export interface QualityOptions {

@@ -3,0 +3,0 @@ quality: string;

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface ResizeOptions {

@@ -3,0 +3,0 @@ w: string;

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface RotateOptions {

@@ -3,0 +3,0 @@ rotate: string;

@@ -1,2 +0,2 @@

import { TransformFactory } from '../types';
import { TransformFactory } from '../types.js';
export interface TintOptions {

@@ -3,0 +3,0 @@ tint: string;

import sharp from 'sharp';
import { ImageConfig } from './types';
import { ImageConfig } from './types.js';
export declare function loadImage(path: string): sharp.Sharp;
export declare function generateImageID(url: URL, config: ImageConfig): string;
{
"name": "imagetools-core",
"version": "4.0.1",
"version": "4.0.2",
"type": "module",

@@ -35,3 +35,3 @@ "types": "dist/index.d.ts",

"@types/sharp": "^0.31.0",
"@vitest/coverage-c8": "^0.30.0",
"@vitest/coverage-c8": "^0.31.0",
"jest-file-snapshot": "^0.5.0",

@@ -42,3 +42,3 @@ "jest-image-snapshot": "^6.0.0",

"typescript": "^5.0.0",
"vitest": "^0.30.1"
"vitest": "^0.31.0"
},

@@ -45,0 +45,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc