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
1
vote
2 answers

How can I fix the error when using the Sharp library?

I want to resize and compress images using sharp library in node.js. The code was taken from this article, but for some reason returns an error. Error PS D:\Code\Web\image-compressor-nodejs> node index.js [Error:…
Tobi
  • 11
  • 1
1
vote
1 answer

Sharp keeps sending response. How to stop it?

I'm trying to resize an image using Sharp module and then render it on GET request path. fs.readFile(`${imageDir}${filename}.jpg`, (err, img) => { if (err) { // File name doesn't match existing images res.send('Error: No image…
1
vote
1 answer

How do I resize an image into a perfect square using sharp in nodejs?

I'm creating the server for an ecommerce web app, and I cannot seem to resize the images into a perfect square. Is it that I need a set width and height to make it a perfect square?
1
vote
1 answer

I can't figure out why I'm getting a ReferenceError: fileUploaded is not defined

Hi this is my first post! Here's the error I'm throwing when trying to submit a post on a website I'm making! This is the error and line 36 is where i call sharp(fileUploaded):…
1
vote
1 answer

Unable to import 'sharp' into next.js project. "Module not found: Can't resolve 'child_process'"

I am trying to import and use sharp in my Next.js project. I have tried uninstalling and reinstalling sharp many times but every time I run npm run dev, this is the error I get. ./node_modules/detect-libc/lib/detect-libc.js:3:0 Module not found:…
cyrus
  • 11
  • 2
1
vote
1 answer

ERROR with sharp dependency when deploying nodejs app to AWS elastic beanstalk

i am a beginner in AWS, and I encountered this problem very early on. I created an EB environment and a code-pipeline in AWS. So whenever I push something to the repository, the app gets deployed. So for now I just have a "Hello world" node.js app,…
1
vote
1 answer

How to convert png pure black & white (no greyscale) with Sharp.js

I need to convert a png with color into a png that is only black and white. I'm currently processing images Sharp.js. But I haven't been able to find a way to generate a monochromatic image. I found a greyscale option. const sharp =…
Ben Downey
  • 2,575
  • 4
  • 37
  • 57
1
vote
1 answer

Unable to run npm install in a gatsby project

I'm working on a project where I'm unable to run npm install as I'm getting the following error. npm WARN deprecated axios@0.18.1: Critical security vulnerability fixed in v0.21.1. For more information, see…
Bhawna Saroha
  • 603
  • 1
  • 11
  • 28
1
vote
1 answer

Sharp NodeJS: How to add an overlay to an animated gif?

I'm trying to make a composition on an animated gif. The overlay appears only for a small instance. I suppose that's because it's being applied only on one frame/page. So my question is, how do I apply the overlay to all the pages/frames in the gif…
Red Vic
  • 115
  • 1
  • 7
1
vote
1 answer

Is it possible to create a tile 2x2 mosaic using Sharp Node?

Using Image Magick I was able to use montage to make this: With this code: montage -density 300 -tile 2x0 -geometry 150x150^ -gravity center -crop 150x150+0+0 -border 0 '.$img_array.' /var/www/html/uploads/output.jpg I would like to know if this…
NineCattoRules
  • 2,253
  • 6
  • 39
  • 84
1
vote
1 answer

No space left on device - AWS Lambda + Sharp

I am trying to convert SVG to TIFF using sharp. My NodeJs application is deployed on AWS Lambda. As the AWS Lambda /tmp directory can have maximum size of 512 MB, for the large files I am getting error "No space left on device". I tried to search…
Nishant
  • 155
  • 11
1
vote
1 answer

Resizing images from AWS S3 with Node.js and Sharp

I am trying to create an endpoint on my API where I can resize images from S3 on demand. I have got it working but it takes roughly 7s to return the resized image compared to roughly 800ms to return the image without resizing. I am new to…
willptswan
  • 61
  • 1
  • 4
1
vote
1 answer

UnhandledPromiseRejectionWarning: ReferenceError: request is not defined || sharp

I am using sharp and would like to make a image editing discord bot. I need to use URLs for this of course so I tried that and saw a request function in the GitHub page. However, it doesn't seem to work for me. The error is in the title here is the…
Yaumama
  • 17
  • 6
1
vote
0 answers

How to use Sharp in discord.js to create a welcome image

I recently switched from Canvas to Sharp to create the welcome image that pops up in the welcome channel every time a user joins since I heard that Sharp is more faster than Canvas. I didn't have any error when I was using Canvas, but in Sharp I got…
Caladan
  • 2,261
  • 2
  • 6
  • 19
1
vote
1 answer

pm2 keep auto restarting on image upload

I am very close to release and while I was testing, I realized my api restarts on image upload, giving me 502 error. I realized pm2 was restarting on image upload endpoint - since it is not logging any error on api side, it must have been server…
Damian
  • 934
  • 8
  • 12