Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wix/image-kit

Package Overview
Dependencies
Maintainers
21
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/image-kit

Standard library for generating canonical URL's for optimally consuming images at Wix

  • 1.45.0
  • npm
  • Socket score

Version published
Weekly downloads
4K
decreased by-33.31%
Maintainers
21
Weekly downloads
 
Created
Source

Image Kit

Standard library for generating canonical URL's for optimally consuming images at Wix.

Features

  • Maintaining pixel perfect images
  • Ensuring minimum download latency, maximum performance and maximum quality
  • Optimizing images for Retina displays
  • Fetching .webp images where applicable
  • Handling image sharpening when needed
  • Optimizing image upscaling (Wix machine learning) when needed

Example

import { sdk } from '@wix/image-kit';

const img = new Image();

img.src = sdk.getScaleToFillImageUrl('some-image.jpg', 1200, 800, 640, 480, { quality: 90 });

Installation

You have 2 options:

Install package

In public (as open-source, dist only)

You can install the package via npm/yarn

> npm install -s @wix/image-sdk

or:

> yarn add @wix/image-sdk

At Wix (with source)

You can install the package via npm/yarn

> npm install -s @wix/image-kit --registry http://npm.dev.wixpress.com/

or:

> yarn add @wix/image-kit --registry http://npm.dev.wixpress.com/

API

MethodDescription
getScaleToFitImageURL()Scales the designated image to fit in the given target width and height while retaining the original proportions.
getScaleToFillImageURL()Scales the designated image with the exact given target width and height while retaining the original proportions. If the required proportions are different than the original, the image may be cropped to fill the provided width and height, so that only part of the original image might be visible.

The position pointing to the place from which to crop the image, if needed, is set by default to the vertical and horizontal center of the image or set to the focalPoint x,y values if presented.
getCropImageURL()Crops the designated image based on the supplied coordinates, starting at the x, y pixel coordinates, along with the width and height options. The image might be scaled according to the target dimensions.

Methods

getScaleToFitImageUrl

getScaleToFillImageUrl(
    relativeUrl,
    sourceWidth,
    sourceHeight,
    targetWidth,
    targetHeight,
    options
)
arguments
namedescriptiontype
relativeUrlthe original image uristring
sourceWidththe original image widthnumber
sourceHeightthe original image heightnumber
targetWidthtarget container widthnumber
targetHeighttarget container heightnumber
optionsadditional image settings [optional]object
options
{
   filters: {
      blur: 15
   },
   unsharpMask: {
      amount: 0.66,
      radius: 1.0,
      threshold: 0.01
   },
   name: 'hello kitty',
   quality: 80,
   upscaleMethod: 'classic',
   watermark: '3856-9876-76890-xzxz',
   isSEOBot: true,
   autoEncode: true,
}
keyvalid valuesdefaulttype
filters.blur0-100-number (%)
unsharpMask.amount0-100.66float
unsharpMask.radius0.1-5001.0float
unsharpMask.amount0-2550.01float
nameany string''string
quality5-9080number
upscaleMethod'auto', 'classic', 'super''auto'string
watermarkwatermark manifest id-string
isSEOBottrue or falsefalseboolean
autoEncodetrue or falsetrueboolean
hasAnimationtrue, false, undefinedfalseboolean
returns

returns image url [string]

getScaleToFillImageURL

getScaleToFillImageUrl(
    relativeUrl,
    sourceWidth,
    sourceHeight,
    targetWidth,
    targetHeight,
    options
)
arguments
namedescriptiontype
relativeUrlthe original image uristring
sourceWidththe original image widthnumber
sourceHeightthe original image heightnumber
targetWidthtarget container widthnumber
targetHeighttarget container heightnumber
optionsadditional image settings [optional]object
options
{
   filters: {
      blur: 15
   },
   unsharpMask: {
      amount: 0.66,
      radius: 1.0,
      threshold: 0.01
   },
   focalPoint: {
      x: 50,
      y: 50
   },
   name: 'hello kitty',
   quality: 80,
   upscaleMethod: 'classic'
   watermark: '3856-9876-76890-xzxz',
   isSEOBot: true,
   autoEncode: true
}
keyvalid valuesdefaulttype
filters.blur0-100-number (%)
unsharpMask.amount0-100.66float
unsharpMask.radius0.1-5001.0float
unsharpMask.amount0-2550.01float
focalPoint.x0-100-number (%)
focalPoint.y0-100-number (%)
nameany string''string
quality5-9080number
upscaleMethod'auto', 'classic', 'super''auto'string
watermarkwatermark manifest id-string
isSEOBottrue or falsefalseboolean
autoEncodetrue or falsetrueboolean
hasAnimationtrue, false, undefinedfalseboolean
returns

returns image url [string]

getCropImageURL

getCropImageUrl(
    relativeUrl,
    sourceWidth,
    sourceHeight,
    cropX,
    cropY,
    cropWidth,
    cropHeight,
    targetWidth,
    targetHeight,
    options
)
arguments
namedescriptiontype
relativeUrlthe original image uristring
sourceWidththe original image widthnumber
sourceHeightthe original image heightnumber
cropXthe X pixel coordinate to start cropping fromnumber
cropYthe Y pixel coordinate to start cropping fromnumber
cropWidththe width constraintnumber
cropHeightthe height constraintnumber
targetWidthtarget container widthnumber
targetHeighttarget container heightnumber
optionsadditional image settings [optional]object
hasAnimationtrue, false, undefinedfalse
options
{
   filters: {
      blur: 15
   },
   unsharpMask: {
      amount: 0.66,
      radius: 1.0,
      threshold: 0.01
   },
   focalPoint: {
      x: 50,
      y: 50
   },
   name: 'hello kitty',
   quality: 80,
   upscaleMethod: 'classic',
   watermark: '3856-9876-76890-xzxz',
   isSEOBot: true,
   autoncode: true
}
keyvalid valuesdefaulttype
filters.blur0-100-number (%)
unsharpMask.amount0-100.66float
unsharpMask.radius0.1-5001.0float
unsharpMask.amount0-2550.01float
nameany string''string
quality5-9080number
upscaleMethod'auto', 'classic', 'super''auto'string
watermarkwatermark manifest id-string
isSEOBottrue or falsefalseboolean
returns

returns image url [string]

FAQs

Package last updated on 27 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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