npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wix/image-kit

v1.64.0

Published

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

Downloads

16,820

Readme

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

| Method| Description | | ------ | ----------- | | 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

| name| description | type| | ------ | ----------- | ------ | | relativeUrl| the original image uri | string | | sourceWidth | the original image width | number | | sourceHeight | the original image height | number | | targetWidth | target container width | number | | targetHeight | target container height | number | | options | additional 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,
}

| key| valid values| default | type| | --------- | -------- |---------| ------ | | filters.blur| 0-100 | - | number (%) | | unsharpMask.amount| 0-10 | 0.66 | float | | unsharpMask.radius| 0.1-500 | 1.0 | float | | unsharpMask.amount| 0-255 | 0.01 | float | | name| any string | '' | string | | quality| 5-90 | 80 | number | | upscaleMethod| 'auto', 'classic', 'super' | 'auto' | string | | watermark| watermark manifest id | - | string | | isSEOBot| true or false | false | boolean | | autoEncode| true or false | true | boolean | | hasAnimation| true, false, undefined | false | boolean |;

returns

returns image url [string]

getScaleToFillImageURL

getScaleToFillImageUrl(
    relativeUrl,
    sourceWidth,
    sourceHeight,
    targetWidth,
    targetHeight,
    options
)

arguments

| name| description | type| | ------ | ----------- | ------ | | relativeUrl| the original image uri | string | | sourceWidth | the original image width | number | | sourceHeight | the original image height | number | | targetWidth | target container width | number | | targetHeight | target container height | number | | options | additional 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
}

| key| valid values| default | type| | --------- | ------------ |---------| ------ | | filters.blur| 0-100 | - | number (%) | | unsharpMask.amount| 0-10 | 0.66 | float | | unsharpMask.radius| 0.1-500 | 1.0 | float | | unsharpMask.amount| 0-255 | 0.01 | float | | focalPoint.x | 0-100 | - | number (%) | | focalPoint.y | 0-100 | - | number (%) | | name| any string | '' | string | | quality| 5-90 | 80 | number | | upscaleMethod| 'auto', 'classic', 'super' | 'auto' | string | | watermark| watermark manifest id | - | string | | isSEOBot| true or false | false | boolean | | autoEncode| true or false | true | boolean | | hasAnimation| true, false, undefined | false | boolean |;

returns

returns image url [string]

getCropImageURL

getCropImageUrl(
    relativeUrl,
    sourceWidth,
    sourceHeight,
    cropX,
    cropY,
    cropWidth,
    cropHeight,
    targetWidth,
    targetHeight,
    options
)

arguments

| name | description | type | | ------ | ----------- | ------ | | relativeUrl| the original image uri | string | | sourceWidth | the original image width | number | | sourceHeight | the original image height | number | | cropX | the X pixel coordinate to start cropping from | number | | cropY | the Y pixel coordinate to start cropping from | number | | cropWidth | the width constraint | number | | cropHeight | the height constraint | number | | targetWidth | target container width | number | | targetHeight | target container height | number | | options | additional image settings [optional] | object | | hasAnimation | true, false, undefined | false | boolean |;

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
}

| key| valid values| default| type| | --------- | ------------ | ------ | ------ | | filters.blur| 0-100 | - | number (%) | | unsharpMask.amount| 0-10 | 0.66 | float | | unsharpMask.radius| 0.1-500 | 1.0 | float| | unsharpMask.amount| 0-255 | 0.01 | float| | name| any string | '' | string | | quality| 5-90 | 80 | number| | upscaleMethod| 'auto', 'classic', 'super' | 'auto' | string | | watermark| watermark manifest id | - | string | | isSEOBot| true or false | false | boolean |

returns

returns image url [string]