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
1 answer

Express, resizing an image prior to uploading to Cloudinary using Sharp - Image not resizing

I'm using vite-react frontend with express back end. I'm trying to resize an image using sharp and then upload it to Cloudinary. So far no matter what I try the image never resizes and is always the same size as the original. I'm sending the image…
JohnM
  • 71
  • 7
1
vote
1 answer

Using sharp with formidable

I try to use sharp with formidable in order to resize my image and change the format but it does not work as expected. The created file is not with the correct format and the correct extension. My code : form.on('fileBegin', function(name, file) { …
tonymx227
  • 5,293
  • 16
  • 48
  • 91
1
vote
0 answers

How to return the value of a promise when using nodejs sharp image library with aws lambda

I want to return a resized image through a aws lambda function using sharp but I can't seem to find out how to return the resized image from the promise as a response const aws = require('aws-sdk'); const s3 = new aws.S3({ apiVersion:…
1
vote
1 answer

svg straight lines curved after converting to raster format (png, jpg) Sharpjs

EDIT: https://github.com/lovell/sharp/issues/1421 Use density option I am converting this svg: https://www.svgviewer.dev/s/fEKKksfU, to png using Sharp.js but it always comes out looking wonky. Here is how I convert it: sharp(Buffer.from(`SVG…
Skn
  • 11
  • 3
1
vote
0 answers

Can't install NPM in cpanel with sharp any version

I am using sharp to convert images to webp (project developped with angular + nodejs), it works only localy because i have error when i deploy using Cpanel (nodejs apps), i checked with different versions (latest 0.31.1, 0.27.0 and also 0.23.0 ..).…
itdev
  • 43
  • 1
  • 6
1
vote
1 answer

gatsby-plugin-image macOS Catalina

I realized that Gatsby 5 requires node 18 and up. I didn't realize that in order to use the gatsby-plugin-image I also need to upgrade my macOS (OSX 10.15 Catalina) to Big Sur or higher!?!? While trying to run it on my Catalina I am getting the…
Refael
  • 145
  • 2
  • 12
1
vote
1 answer

Getting a sharp libvips npm install error (MacOS)

I am trying to run npm install for my Gatsby project on macOS Ventura. sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy) I've looked through all of the previous tickets relating…
Rebecca
  • 25
  • 3
1
vote
0 answers

I have a problem with chaining functions while resizing an image and displaying it in the browser according to the URL params

I'm a total beginner with backend, node and express I'm trying to build an api that resize the image according to the entered params in the URL and render it in the browser using typeScript, so I'm using sharp to resize the image, express to build…
1
vote
1 answer

How to return image NOT in base64

Season's greetings, We have a lambda that: Step 1: Downloads image from S3 Step 2: Resizes and formats the image using sharp Step 3: Return a 200 response with the image in body like so: const sharpPipe = sharp() .resize(300, 300) …
Izak Joubert
  • 906
  • 11
  • 29
1
vote
1 answer

Resize image before uploading to google cloud using node js sharp

I'm writing code on image upload function to google cloud. I'm able to upload image to gcloud but not able resize it before uploading. I tried with node js sharp library to resize but not able to implement it properly. Here is my code below: My…
David
  • 539
  • 3
  • 9
  • 23
1
vote
0 answers

sharp can't be installed using npm

when running npm install sharp gives me the following error npm ERR! code 127 npm ERR! path /root/.nvm/versions/node/v16.18.1/lib/node_modules/sharp npm ERR! command failed npm ERR! command sh -c -- (node install/libvips && node install/dll-copy &&…
Andrew Naem
  • 162
  • 12
1
vote
1 answer

Nodejs sharp.toBuffer() crashes without output

So I want to use the sharp package in combination with canvas to process and draw some images in Nodejs. When I try to load an image using sharp like this: const buffer = await…
HimmDawg
  • 97
  • 10
1
vote
0 answers

Installing npm sharp module on Ubuntu failed

I faced issue while was trying to install sharp module on ubuntu server. I tried to install it to my project folder but had no success there. I had a guess that this might happen due to some conflicts with current modules. After that I tried to…
1
vote
0 answers

How to fix the ReferenceError: __dirname is not defined error when it's coming from a third party library?

I'm trying to import the sharp package to my function. I'm trying to create a lambda function using the SST framework. The problem is, Im getting the following error: Runtime.UnhandledPromiseRejection: ReferenceError: __dirname is not defined in ES…
THpubs
  • 7,804
  • 16
  • 68
  • 143
1
vote
0 answers

How to encode a composited sharp image into a Redis queue without corrupting the text?

I wish to render an image in sharp by putting an SVG on top of a canvas and put this image into a Redis queue to be consumed by another service. When I test the rendering of the image without placing it into the queue, everything looks…