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
62
votes
6 answers

Sharp image library rotates image when resizing?

When using the sharp image resize library https://github.com/lovell/sharp for node.js, the image is being rotated. I have no code thats says .rotate(), so why is it being rotated and how can I stop it from rotating? I'm using the…
JK.
  • 21,477
  • 35
  • 135
  • 214
35
votes
10 answers

How to fix Something went wrong installing the "sharp" module and Cannot find module '../build/Release/sharp.node' in expo

I tried to install expo after I executed the command exp start but I got: Something went wrong installing the "sharp" module Cannot find module '../build/Release/sharp.node'. How can I fix this problem?
zaki tutu
  • 595
  • 3
  • 7
  • 16
31
votes
24 answers

Can't install Sharp

When running sudo npm i sharp --save I get the following errors: > sharp@0.21.3 install /home/server/node_modules/sharp > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy) info sharp…
Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137
24
votes
5 answers

MAC M1 Something went wrong installing the "sharp" module

Running npm run dev (gatsby develop) on MacBook Pro M1 chip exit with Error: Something went wrong installing the "sharp" module Running npm run dev MacBook Pro intel chip works fine. I've seen similar post which did not solved my problem : When…
crg
  • 4,284
  • 2
  • 29
  • 57
21
votes
3 answers

How to resize an image in sharp with the option 'contain' but preserve the aspect ratio of the original dimensions?

I have a 1000px by 750px image. I use lovell/sharp to resize it: await sharp(image) .resize({ fit: sharp.fit.contain, width: 800, height: 800 }) .jpeg({ quality: 80 }) .toBuffer() This results in a new image…
user1031947
  • 6,294
  • 16
  • 55
  • 88
20
votes
3 answers

Compress image using sharp in node.js

I want to resize and compress images using sharp in node.js In sharp for jpeg there is separate compression and for webp there is separate and for png there is separate. WEBP sharp('a.jpg') .resize(1000) .webp({quality: 80}) JPEG sharp('_4_.jpg') …
Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133
19
votes
2 answers

How do I convert a base64 string formatted image to the datatype sharp image downsizer expects?

I'm trying to downsample an image in node. I have that image stored as a base64 encoded string (ie: "data:image/png;base64,iVBOR" etc.). I'm using Sharp npm package. The documentation appears to delineate that sharp can take either the filepath…
18
votes
3 answers

Can we get height and width of image using sharp?

I am using sharp to resize bulk of image. So I am resizing them to 500px by preserving their aspect ratio. Also I want to resize height to 500px and auto resize width if height is greater than width and vice versa. To do that I need to get image,…
classydraught
  • 352
  • 1
  • 4
  • 13
16
votes
8 answers

Error running Sharp inside AWS Lambda function: darwin-x64' binaries cannot be used on the 'linux-x64' platform

When attempting to run sharp inside an AWS Lambda function, I keep getting the following error: darwin-x64' binaries cannot be used on the 'linux-x64' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install' I…
Keith Harris
  • 1,118
  • 3
  • 13
  • 25
14
votes
3 answers

Installing Sharp /usr/include/vips/vips8:35:25: fatal error: glib-object.h

I am trying to install sharp on Ubuntu 16.04 LTS. I originally did not have vips, so I installed sudo apt-get install libvips-dev That fixed the first error, but now I get another error that I am stuck on: In file included from…
Rachel
  • 141
  • 1
  • 1
  • 4
14
votes
2 answers

(node.js module) sharp image processor keeps source file open, unable to unlink original after resize

I'm using sharp to resize an uploaded image in a Node.js / Express application written in Typescript. After successful resizing, I'd like to delete the original file. For png and gif input images, the operation terminates successfully, I have the…
András Szepesházi
  • 6,483
  • 5
  • 45
  • 59
13
votes
7 answers

Fail to install gatsby starter because of sharp

I got these error in terminal when I want to install a gatsby starter. Anyone get any idea how to solve it? [4/4] Building fresh packages... [6/13] ⠁ sharp [-/13] ⠁ waiting... [-/13] ⠁ waiting... [12/13] ⠁ sharp error…
Wing Cheung Kwok
  • 153
  • 1
  • 1
  • 6
13
votes
4 answers

nodejs Sharp: transparent into white

I am using Nodejs Sharp to transcode/resize png images into jpg. Is there way to replace transparent with white (or other light color) rather than black? I found solution for an older library but Sharp seems to be fastest and greatest. .background…
Serge
  • 3,387
  • 3
  • 16
  • 34
9
votes
3 answers

Install sharp without GitHub fetch for Nextjs: Error: Cannot find module 'sharp'

I'm trying to use Next.js on my corporate system, but whenever I run "npm run build", the build fails with the message: Error: Cannot find module 'sharp' I tried installing sharp but I get this error: info sharp Downloading…
Abhijeet Singh
  • 994
  • 11
  • 27
8
votes
2 answers

ESBuild error: No loader is configured for ".node" files: node_modules/sharp/build/Release/sharp.node

I am trying to make an esbuild plugin that converts GIF to PNG using Sharp but I get the following error: ❯ npx esbuild .\src\utils\gif-to-png.ts --platform=node --bundle node_modules/sharp/lib/utility.js:7:22: error: No loader is configured for…
deadcoder0904
  • 7,232
  • 12
  • 66
  • 163
1
2 3
30 31