Questions tagged [sharp]
Questions about sharp, a Node.js image processing library to resize, crop and optimize JPEG, PNG, WebP and TIFF images.
sharp
479
questions
71
votes
6
answers
24k
views
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 ...
40
votes
11
answers
49k
views
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 ...
34
votes
26
answers
120k
views
Can't install Sharp
When running sudo npm i sharp --save I get the following errors:
> [email protected] install /home/server/node_modules/sharp
> (node install/libvips && node install/dll-copy && ...
24
votes
5
answers
25k
views
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 ...
23
votes
3
answers
28k
views
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: ...
23
votes
3
answers
40k
views
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(...
23
votes
2
answers
17k
views
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 ...
22
votes
3
answers
24k
views
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 ...
18
votes
2
answers
12k
views
(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 ...
17
votes
9
answers
13k
views
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/...
16
votes
7
answers
13k
views
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...
...
15
votes
3
answers
12k
views
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 ...
14
votes
4
answers
20k
views
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 ...
11
votes
8
answers
14k
views
Could not load the "sharp" module using the win32-x64 runtime (Strapi)
I used to use a Node.js v16.x installed locally to run Strapi which worked well.
But recently I had to update it to Node.js v18.x due to another project, so I installed NVM to manage multiple Node.js ...
10
votes
1
answer
8k
views
Express Sharp install via Docker issue
I need to use sharp. Its work fine on my workspace but if I deploymeny via docker then I get error. I am implementation all steps.
Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' ...
9
votes
3
answers
9k
views
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 ...
9
votes
3
answers
13k
views
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/...
8
votes
1
answer
1k
views
How to allow optional sharp image in graphql gatsby?
I typically have frontmatter that will have an array of objects, inside each object will be an image which will reference a string of a file relative to the markdown file.
The problem is, the array ...
8
votes
2
answers
18k
views
Sharp error: [Error: Input file is missing]
I download the image through request, and then process the image through sharp.
But there is an error that input file is missing, actually the variable body has a value.
import { IADLandingPageABTest ...
8
votes
1
answer
10k
views
How can you resize an image in NodeJS using Sharp having only a URL, using async/await, and without a local copy being created?
I'm working in an environment where the available image processing library is NodeJS's Sharp for scaling images. It has been stable as it is being pipe based, but I'm tasked with converting it into ...
8
votes
1
answer
3k
views
NodeJS Sharp Node Package Memory Consumption Issue
I am working on a NodeJS project that is using sharp node package for resizing JPEG/JPG images.
The problem is Node process keeps adding the processed file in memory and never releases it.
As a ...
8
votes
0
answers
2k
views
converting heic image to png / jpeg with sharp node.js
When I want to convert png file like this
const file = await this.awsS3Service.getObject(fileEntity.awsS3Key);
const body = await this.awsS3Service.streamToBuffer(file.Body as Readable);
const ...
8
votes
0
answers
3k
views
Issue With NodeJS Memory Consumption Statistics - Huge RSS & External Memory Usage
While working on performance testing for a Node Project, I came across some memory reports which are a bit confusing to interpret in terms of performance and memory leaks.
Background
So I generated ...
7
votes
2
answers
2k
views
sharp error: Package OpenEXR was not found in the pkg-config search path
I executed npm install on gatsby js directory on Mac.
macOs is Big Sur
Version is 11.4.
gatsby version is 3.11.0
gatsby-plugin-sharp version is 3.11.0
this error log is shown.
npm ERR! code 1
npm ...
7
votes
2
answers
10k
views
Nodejs Sharp webp lossless compression
I'm developing a similar service of Imgix and I'm using Sharp.
But the webp lossless compression Imgix get better results than Sharp. The same image with the same width and height in Imgix have 453 ...
7
votes
1
answer
3k
views
Why does Sharp output the same file, even though I have changed the input file?
After scaling and coloring a JPG with Sharp, I immediately delete the input file. When I upload a new file with the same name, Sharp will output the old file. I'm running NodeJS on Ubuntu 16.04.
Here ...
7
votes
5
answers
9k
views
Gatsby new fails to install the sharp package and breaks
I can't initiate a gatsby starter project. The new command process breaks down during initialization, and results in an error and non-compilable project.
Here's the command:
> gatsby new gatsby-...
7
votes
3
answers
4k
views
Sharp package Heroku deployment issue
I'm deploying my NodeJs app to Heroku. No issues running the app with nodemon locally.
However when I'm trying to push to Heroku Master, seems like "sharp" package is causing an issue:
remote: ----...
7
votes
7
answers
10k
views
How run next.js with node-sharp for docker
I have a problem implementing sharp for Dockerfile.
Error: 'sharp' is required to be installed in standalone mode for the image
optimization to function correctly
Next.js with sharp works fine for ...
7
votes
1
answer
5k
views
Cordova-res not installing in ionic cordova
I am not able to install package Cordova-res in ionic 5.4.4v and getting the error below
**Z:\my program V2\ionicTest\testProj>npm i -g cordova-res**
C:\Users\USER\AppData\Roaming\npm\cordova-res ...
7
votes
1
answer
951
views
build sharp for specific platform with esbuild and deploy it with NodejsFunction lambda
I'm trying to deploy a Lambda function which uses sharp for image processing.
I do not want to use docker builds -- I have to use esbuild.
Here is my lambda definition in cdk:
const ...
7
votes
6
answers
18k
views
I cant install sharp using npm
I cant install sharp library using sudo npm install sharp.
The terminal output:
[email protected] install /Users/kozakiewicz/node_modules/sharp
(node install/libvips && node install/dll-copy &...
7
votes
2
answers
8k
views
Watermark with sharp
I have a image and i put watermark there, but i want that watermark hs a opacity like 30%.
My code:
let sharp = require('sharp');
let buffer = null;
await sharp(image)
....
6
votes
2
answers
3k
views
NodeJS: Illegal instruction (core dumped) Error after using sharp library
When I add this piece of code from sharp package (that is a image processing package):
await sharp(req.file.path)
.resize(500)
.jpeg({ quality: 50 })
.toFile(path.resolve(req.file....
6
votes
2
answers
12k
views
Can I directly process buffer data using Sharp in NodeJs
I get buffer data to my program from external and I want to process buffer data and send it as a buffer also.
So I don't want to convert buffer into an image.
How can I do this?
I try this way but it ...
6
votes
1
answer
12k
views
Next.js: how to apply sharp lib in Next.js
next/image changes too slow, so I see the old images and then new images appear. For this issue, I have referred below:
Next/Image's components are too slow to appear
Install sharp by running ...
6
votes
2
answers
2k
views
How to use images from sharp module in React and Webpack project
Here is a codesandbox I would like the image in it to be processed by the sharp module. I want it to do this because I want this module to web optimize all the images in my React project, and to ...
6
votes
2
answers
3k
views
How to resize image from S3 with Sharp?
I am trying to resize the uploaded image from S3 using @aws-sdk/v3 in Node.js API.
First, I get the object (image) from S3 as shown here: https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/...
6
votes
2
answers
4k
views
Resize one image multiple times
I am resizing a given image (saved on disk) to different sizes:
var image = 'photos/pic';
var sizes = [1440, 1080, 720, 480];
for (var i = 0; i < sizes.length; i++) {
sharp(image + '.jpg')
...
6
votes
0
answers
1k
views
win32-x64 binaries cannot be used on the 'linux-x64' platform
'win32-x64' binaries cannot be used on the 'linux-x64' platform got this error while installing node sharp on windows system. This is breaking my lambda code on aws while execution.
5
votes
1
answer
8k
views
Failed to find the instance of sharp used by the global sharp-cli package
When attempting to run Expo for web I get the error "Failed to find the instance of sharp used by the global sharp-cli package" after creating a file namedwebpack.config.js in the root of my ...
5
votes
2
answers
6k
views
How to send the resized image from sharp back to user?
I'm trying to make an image resizing API through SharpJS and my code follows as per the following
require('dotenv').config();
const express = require('express');
const sharp = require('sharp');
const ...
5
votes
2
answers
4k
views
Utilizing custom font in AWS Lambda and Node.js 12.x
I'm trying to create an AWS Lambda function to apply a watermarking effect on images. The original image will be pulled from S3, the watermarks applied and the results uploaded back to S3.
I'm using ...
5
votes
4
answers
7k
views
Google Cloud Functions error: "Cannot find module 'sharp'" but it's in my package.json
I am trying to deploy a function to Google Cloud Functions. I based it on their ImageMagick tutorial.
Every time, the function fails to deploy because it reaches an error. Looking at the log, the ...
5
votes
2
answers
1k
views
How to resize and image before saving it with gridfs?
i'm a beginner with mongoDB and gridfs. I have a code which save in the database an incoming image. But I'd like to resize the image before saving it. It tried to use sharp, but I don't really ...
5
votes
3
answers
5k
views
Error when trying to install Sharp for Gatsby
I'm new to using Gatsby. I am able to use the default starter for Gatsby, but any other starter seems to rely on Sharp, and the installation of that is failing no matter what I do.
info sharp ...
5
votes
2
answers
13k
views
Sharp Error: Input buffer contains unsupported image format
I want to create image manipulation on the image fetched from the AWS S3 and would like to perform manipulation action on it. I am using stream to solve the problem of loading big files.
import AWS ...
5
votes
0
answers
2k
views
Sharp Input file contains unsupported image format when calling .toBuffer()
When calling the .toBuffer() method on a sharp object, I get the following error:
Input buffer contains unsupported image format
I'm fetching an image from S3, and I am certain its retrieved as a ...
4
votes
4
answers
5k
views
Error: darwin-x64' binaries cannot be used on the 'linux-x64' platform (AWS lambda + typescript + webpack sharp module )
aws lambda with typescript is occured error when bundle by webpack.
Before bundle webpack, I did "npm i --arch=x64 --platform=linux --target=12.14.1 sharp" and labmda is working properly.
...
4
votes
5
answers
9k
views
Something went wrong installing the "sharp" module
I already do what the error said. I removed the sharp then npm install --ignore-scripts=false --verbose but it still doesn't work.
I also tried the:
rimraf node_modules
rimraf yarn.lock
yarn
What ...