Questions tagged [sharp]

Questions about sharp, a Node.js image processing library to resize, crop and optimize JPEG, PNG, WebP and TIFF images.

The typical use case for this high speed module is to convert large images in common formats to smaller, web-friendly JPEG, PNG and WebP images of varying dimensions.

Resizing an image is typically 4x-5x faster than using the quickest [tag:imagemagick and settings.

Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly. Lanczos resampling ensures quality is not sacrificed for speed.

As well as image resizing, operations such as rotation, extraction, compositing and gamma correction are available.

Most 64-bit OS X, Windows and Linux (glibc) systems running Node versions 4, 6, 8 and 9 do not require any additional install or runtime dependencies.

Download Sharp

455 questions
3
votes
2 answers

Non crop resize to png with node.js and Sharp package

I am trying to resize images/transform to png with Nodejs sharp package without cropping. According to documentation it is .max() method, which regretfully does not work (image is croped) when resizing to png. Any workarounds?
Serge
  • 3,387
  • 3
  • 16
  • 34
3
votes
1 answer

Error installing sharp with npm on macOS

If I create a fresh npm project: mkdir ~/test cd ~/test npm init -y And then try to install sharp: npm install --save sharp I get the following error messages: > sharp@0.18.4 install /Users/hsribei/tmp/test/node_modules/sharp > node-gyp…
agentofuser
  • 8,987
  • 11
  • 54
  • 85
3
votes
0 answers

Failed at the sharp@0.18.2 install script 'node-gyp rebuild'

Facing issue while build docker file.here is my docker file and local ubuntu machine it's working but with docker, i can build it successfully. the error throw from npm sharp all other module working fine. npm ERR! Linux 4.4.0-83-generic npm ERR!…
Developer
  • 175
  • 1
  • 4
  • 12
3
votes
0 answers

Remove a white background - sharp library

Is it possible to replace a white background of an image with transparency using the sharp library?
Brian F
  • 1,620
  • 1
  • 19
  • 23
2
votes
1 answer

Create GIF using nodejs and sharp

I am struggling to create a gif using the sharp library in nodejs. I am able to successfully create the frame-images that I want to use for the gif, but am not able to use them to create a gif. I am not sure if sharp even supports what I want to do,…
Nik
  • 2,863
  • 6
  • 24
  • 29
2
votes
0 answers

NodeJS using package Sharp to resize images. How do I resize based on the long side of the image?

In Lightroom, I can resize images to a pixel value for the long side. That way if, for example, an image is five times as tall as it is wide, and I asked for a 2,000px (long side) image, the result will be 2000x400px. Not 10,000x2,000px. In other…
icor103
  • 193
  • 1
  • 8
2
votes
1 answer

unable to open for write unix error: No such file or directory. How to fix?

I'm trying to convert png to avif via Sharp, but I'm getting an error. Code example const image = sharp(`./images/img/original/image.png`) .avif({quality: 70, loseless: true}) .toFile(`/images/img/avif/out.avif`) Error [Error:…
Zorome
  • 106
  • 8
2
votes
1 answer

dyld: lazy symbol binding failed

I am running into a weird error when i try to run gatsby develop inside a newly created gatsby project. This should not have anything to do with gatsby.js (a static site generator), since I have been getting the same error on different occasions as…
2
votes
0 answers

AWS Amplify: How to install sharp in Lambda Trigger?

I am new to using AWS Amplify and AWS Lambda and I'm facing a problem that I can't solve on my own. Explanation: I ran the command: amplify add storage This command generated for me the trigger below: exports.handler = async function (event) { …
jonathan
  • 105
  • 7
2
votes
1 answer

Type issue in build with sharp in Next.js app

In the image below, I can't yarn build the app. I'm using Plaiceholder that depends on Sharp. Everything is working fine, but when I build the app it crashes. Versions that I'm using: "react": "17.0.2" "next": "12.1", "sharp":…
2
votes
1 answer

simple Api for resizing image using typescript and sharp

I'm making an API that takes an image from the database by getting it using the URL like this (http://localhost:3000/city/?name=encenadaport&width=200&height=200) I made the code and the function that handle the resizing issue the problem is when I…
2
votes
1 answer

How does Nodejs handle relative paths?

I have a question regarding Nodejs's path-handling. I know that they have a page about that in the docs but it didnt contain what I needed. So basically, I have a file that includes a relative path referencing a file (png in this case). Now, based…
2
votes
1 answer

Sharp unable to read file buffer

I'm using express-fileupload for reading files from the API. Now I want to process the image in the request body using Sharp. I don't want to first save the file at the server and process it using fs.readFileSync. I tried passing…
IshduttT
  • 179
  • 1
  • 14
2
votes
0 answers

Node.js: Image from S3 to be manipulated with Sharp

I have images stored in Amazon S3. Image types include jpg, png and svg. I have a typescript node backend where I should retrieve an image from S3 bucket to be rotated with Sharp library. I'm using aws-sdk to get the object, but I'm having problems…
Namiskuukkwl
  • 165
  • 1
  • 6
2
votes
1 answer

A better way to round a list of const variables in Javascript for gulpfile.js?

In my gulpfile.js, I want to be able to calculate widths based on the approximate percentage of the screen that they will occupy for an image sizing/compression task using the gulp plugin "gulp-sharp-responsive". For example, one of my sizes for a…
Sam Miller
  • 95
  • 1
  • 6