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

Copying an image, reading its metadata, and writing back with streams and sharp

I am trying to write a Lambda function that takes an image stored as an S3 object, reads its height and width, and moves it to a different prefix in the same bucket. Then, it takes the image and resizes it while keeping the original aspect ratio,…
Joey Dumont
  • 898
  • 2
  • 7
  • 25
2
votes
1 answer

SVG as SVG's image tag not working while using with sharp

I'm using sharp to convert the file but sharp gives me an empty png file. I want to use a base64 formatted SVG image as tag's source and want to convert it to a png file. Here's an example to show what I'm trying to do; const sharp =…
Kevin S
  • 37
  • 1
  • 5
2
votes
0 answers

SharpJS pipe memory leak on linux

I'm reading from a fs readStream (from graphql upload file) and piping it through SharpJS transform function and piping it through a writeStream to write to a file. In my system (windows) it works just fine but in my Host (linux) it creates a core…
MH. Abdi
  • 298
  • 5
  • 22
2
votes
0 answers

sharp [Error: Input file contains unsupported image format]

I am using node's sharp library to do image processing, I am using AWS Lambda with node 10x version to resize the image, as recommended in the sharp library's documentation. I am downloading the image file from AWS S3, To AWS Lambda's /tmp…
Dev1ce
  • 5,390
  • 17
  • 90
  • 150
2
votes
1 answer

Firebase deploy functions with Sharp library fails in Google Cloud Build

After migrating to Google Cloud Build from Bitbucket Pipelines the Firebase deployment is failing. The setup was deploying successfully both on Bitbucket Pipelines and locally. No further explanation is given other than error below. I have comment…
2
votes
1 answer

Transform photo with imagemin before uploading to s3 using multer-s3-transform

I was trying to use multer-s3-transform in uploading my photo to s3, but before that I need to transform the image to much lower file size using imagemin. I was able to do it using sharp but still want to try it using imagemin to specifically set…
virtualninja
  • 192
  • 3
  • 16
2
votes
1 answer

Is there a way to apply CSS styling to lazy-loaded images before they fully load with Gatsby and Sharp?

I use Sharp to lazy-load images on my Gatsby site. At the moment, the images start blurry and "gain focus" when they get on-screen. I'd like to apply CSS stylings or filters on these images while they are still in "blurry mode", and remove it once…
LeKevoid
  • 426
  • 6
  • 19
2
votes
1 answer

Dynamically overlay multiple images with sharp

I'm trying to overlay multiple images using sharp. A self-contained example is shown below, which fails with the error: Error: Input buffer contains unsupported image format The error is thrown during the first overlay operation. My real…
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
2
votes
0 answers

Dynamic content of resize image in sharp aws lambda

I am using sharp to resize images on AWS Lambda. It works fine for testing but the issue is that how to give dynamic content type according to the content type of image. My code is then(buffer => S3.putObject({ Body: buffer, Bucket:…
Haseeb Ahmad
  • 7,914
  • 12
  • 55
  • 133
2
votes
2 answers

Node.JS - SVG to Image Buffer for Sharp's overlayWith() Function?

I'm using the Sharp NPM library with Node.JS and I'm trying to add text to my canvas. I found out here that I need to use .overlayWith(), along with another library that can convert text to an SVG. A comment there suggested to use text-to-svg or…
APixel Visuals
  • 1,508
  • 4
  • 20
  • 38
2
votes
2 answers

Overlaying png onto SVG using Sharp?

I've got a set of png files, that are 4500x5400. What I am trying to do is the following: Draw a circle that is 485x485 at 300dpi Overlay the png inside the circle, so that its resized (scaled) I've been messing around all night but I'm not…
K20GH
  • 6,032
  • 20
  • 78
  • 118
2
votes
1 answer

Sharp image library for AWS Lambda functions in VS Node.js

I'm working on an AWS Lambda function in Visual Studio that calls for fast image resizing. Originally, I was using ImageMagick to resize these images, but the entire process is is taking too long to process. The alternative to ImageMagick seems to…
tbruestle
  • 21
  • 2
1
vote
0 answers

Webpack error with 'sharp-win32-x64.node' binary file in Next.js project

I'm encountering an error when trying to build my Next.js project. The error message mentions a problem with 'sharp-win32-x64.node', which seems to be related to the sharp module and binary files. I'm using Next.js with TypeScript, and I've already…
1
vote
0 answers

malloc error during next build with node >= 18

We have a next.js 12 project built and run on node 16 which works fine but we want to migrate to newer nodes. Going for the next LTS node 18 is a logical step, and next dev works fine, but running next build results in: info - Creating an optimized…
Dan Macak
  • 16,109
  • 3
  • 26
  • 43
1
vote
0 answers

Can I use the sharp library on an image on an external host?

I have a code. sharp('https://external-image.jpeg') .resize(100, 100) .toFile('path_to_my_folder'); This does not work. But if I download this image, and try to resize it: sharp('path_to_local_img') .resize(100, 100) …