Socket
Socket
Sign inDemoInstall

gatsby-plugin-sharp

Package Overview
Dependencies
Maintainers
12
Versions
952
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-sharp

Wrapper of the Sharp image manipulation library for Gatsby plugins


Version published
Weekly downloads
175K
decreased by-1.61%
Maintainers
12
Weekly downloads
 
Created

What is gatsby-plugin-sharp?

gatsby-plugin-sharp is a Gatsby plugin that provides image processing capabilities using the Sharp image processing library. It allows you to perform various image transformations such as resizing, cropping, and creating responsive images.

What are gatsby-plugin-sharp's main functionalities?

Resize Images

This feature allows you to resize images to specified dimensions. In the code sample, the input image 'input.jpg' is resized to 300x200 pixels and saved as 'output.jpg'.

const sharp = require('sharp');
sharp('input.jpg')
  .resize(300, 200)
  .toFile('output.jpg', (err, info) => { console.log(info); });

Crop Images

This feature allows you to crop images to specified dimensions and coordinates. In the code sample, a 300x200 pixel area is extracted from 'input.jpg' starting at coordinates (10, 10) and saved as 'output.jpg'.

const sharp = require('sharp');
sharp('input.jpg')
  .extract({ width: 300, height: 200, left: 10, top: 10 })
  .toFile('output.jpg', (err, info) => { console.log(info); });

Create Responsive Images

This feature allows you to create multiple versions of an image at different sizes for responsive design. In the code sample, the input image 'input.jpg' is resized to 300, 600, and 900 pixels wide, and each version is saved with a different filename.

const sharp = require('sharp');
const sizes = [300, 600, 900];
sizes.forEach(size => {
  sharp('input.jpg')
    .resize(size)
    .toFile(`output-${size}.jpg`, (err, info) => { console.log(info); });
});

Other packages similar to gatsby-plugin-sharp

Keywords

FAQs

Package last updated on 29 Mar 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