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

sqip-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqip-loader

Loads images and exports tiny SQIP previews as image/svg+xml URL-encoded data

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
970
increased by10.35%
Maintainers
1
Weekly downloads
 
Created
Source

npm

SQIP Loader

Loads images and exports tiny SQIP previews as image/svg+xml URL-encoded data

Requirements for non-64bit operating systems

Install

npm install --save-dev sqip-loader

Usage

The sqip-loader loads your image and exports the url of the image as src, the image/svg+xml URL-encoded data as preview, and a dimensions object containing width, height and the type of the imported image.

import { src, preview, dimensions } from './image.png';

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.(gif|png|jpe?g)$/i,
        use: [
          {
            loader: 'sqip-loader',
            options: {
              numberOfPrimitives: 20
            }
          }
        ]
      }
    ]
  }
};

It can also be used in conjunction with url-loader or file-loader.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.(gif|png|jpe?g)$/i,
        use: [
          {
            loader: 'sqip-loader',
            options: {
              numberOfPrimitives: 20
            }
          },
          {
            loader: 'url-loader',
            options: {
              limit: 8192
            }
          }
        ]
      }
    ]
  }
};

Options

NameTypeDefaultDescription
numberOfPrimitives{Number}20SQIP works by first approximating the image with a certain number of shapes, specified by numberOfPrimitives, and then adding a blur effect to it. Larger values will generate sharper previews, but will also increase the size
mode{Number}0Specifies the type of primitive shapes that will be used to generate the image. 0=combo, 1=triangle, 2=rect, 3=ellipse, 4=circle, 5=rotatedrect, 6=beziers, 7=rotatedellipse, 8=polygon
blur{Number}12Specifies the standard deviation of the Gaussian blur
skipPreviewIfBase64{Boolean}falseIf set to true, will not generate a preview if the image already is base64 encoded. Useful when the inlined base64 representation is enough, and you don't want to bloat your files with unused previews

FAQs

Package last updated on 26 Nov 2019

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