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

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') .resize(sizes[i], sizes[i]) .toFile(image + '-'…
Chris
  • 4,255
  • 7
  • 42
  • 83
5
votes
4 answers

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 local developing: next 12.0.1 sharp 0.30.2 node…
miko866
  • 182
  • 2
  • 9
5
votes
0 answers

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 Buffer which is then passed to sharp. Moreover, when…
Michael Gradek
  • 2,628
  • 3
  • 29
  • 35
5
votes
1 answer

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.destination, “resized”, filename)); I get this…
Arman Zanjani
  • 197
  • 11
5
votes
1 answer

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 from 'aws-sdk' import sharp from 'sharp' const s3…
Prashant Singh
  • 137
  • 2
  • 9
5
votes
2 answers

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 understand how it works. I tried the following code, but…
ATM
  • 160
  • 2
  • 10
5
votes
2 answers

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) .composite([{ input: './logo.png', gravity: 'center' }]) …
5
votes
3 answers

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 Downloading…
DJFriar
  • 340
  • 7
  • 21
4
votes
0 answers

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 processUploadedImageLambdaFunction = new NodejsFunction( …
4
votes
1 answer

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 yarn add sharp in your project directory and then reboot…
Uhney
  • 379
  • 1
  • 6
  • 23
4
votes
0 answers

how to use sharp to resize image while uploading to s3 nodejs

I use multer to upload the images to s3. The user clicks on upload button in the frontend, and uploads the image, which is then uploaded to s3 with the helper multer backend. But the images uploaded aren't optimised i.e if the user uploads a 4mb…
Sai Krishnadas
  • 2,863
  • 9
  • 36
  • 69
4
votes
1 answer

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 app folder. The contents of the file can be as simple as…
SupaHam
  • 1,125
  • 2
  • 12
  • 20
4
votes
2 answers

In Nodejs sharp package how to add two image into a single image?

I tried to combine two images into a single image using sharp package in NodeJS but i cant is there any ways to done this with sharp package
4
votes
1 answer

How to Process Uploaded Image with Graphql Apollo with SharpJS in NodeJS?

I have a graphql mutation that gets an image from the frontend, and that then is processed and optimized on my server. But I can't figure out how to pass my image to sharp. Here is my code: const Mutation = { createImage: async (_, { data }) =>…
Anatol
  • 3,720
  • 2
  • 20
  • 40
4
votes
1 answer

multer: How to process and manipulate files before saving?

I want to process images using sharp before saving so I don't need to save the file twice (one by multer and one by sharp). The best way I found is to save the file in memory with initializing multer with no argument: const upload = multer() and…
Arman Zanjani
  • 197
  • 11
1 2
3
30 31