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

Using sharp on serverless offline always fails

When I invoke any function in my serverless application I get an error as below. However, directly installing sharp give me no errors. also, when I run the tests sharp works perfectly. Missing module": /build/Release/sharp-darwin-x64.node" exists in…
mamadou jallow
  • 351
  • 1
  • 2
  • 10
1
vote
0 answers

Docusaurus build fails with "sharp" module issue

Upon yarn build my projects fails to build. I've tried recommended options, but nothing works and error returns every-time. The project works upon using yarn start, just the build doesn't work [ERROR] Unable to build website for locale en. [ERROR]…
Fill
  • 377
  • 2
  • 15
1
vote
0 answers

Node.JS: Watch a folder, modify new files, exclude program's modifications from fs.watch

Currently, I am attempting to write a small Node.JS application that watches a folder for any new images, resizes them with the sharp npm package, then saves them to the same directory. When I do this, fs.watch(...) fires off as if a new file has…
mamoodoon
  • 11
  • 1
1
vote
1 answer

sharp package doesn't work with canvas nodejs

const { createCanvas, loadImage } = require('canvas') const sharp = require("sharp"); This is my code. throw new Error(help.join('\n')); ^ Error: Something went wrong installing the "sharp" module The specified procedure could not be…
Lilyn
  • 35
  • 5
1
vote
1 answer

How to resize an image proportionally using a blur effect, instead of letterboxing, on Node.js?

I have a photo which is a rectangle and I want to resize it down to a square while preserving the aspect ratio. Libraries like Sharp allow you to do that by applying letterboxing to the resulting image. await sharp(photoBuffer).resize({ width: 200,…
Kawd
  • 4,122
  • 10
  • 37
  • 68
1
vote
1 answer

azure functions javascript sharp module

got my nodejs code where I use the sharp library (0.29.3 version) locally works fine when I deploy to the cloud - got an error I use 64-bit platform, node 14 version, and functions version 3 how I can resolve this issue? rebuilt for many times,…
1
vote
1 answer

Saved Media file has unsupported type using sharp in nodejs

I am trying to fetch the image from a remote url, resize it and save it to my computer locally. For this, i am using got library which returns a buffer. i take that buffer and resize the image and then store it in a file using sharp js. Here is my…
Nothing
  • 78
  • 5
1
vote
0 answers

Sharp resize function modifies image metadata

I am resizing images in node using the sharp library. The function doing the resizing is in a separate module: import sharp from "sharp"; const resize = async (sizes, sourceImageBuffer) => { const resizeResults = await Promise.allSettled( …
handris
  • 1,999
  • 8
  • 27
  • 41
1
vote
1 answer

GCS catch error if file not found in bucket while streaming download

I am trying to fetch images from google cloud storage bucket from browser and serving the files using API in express. Following code breaks when the Image path is invalid. The try catch doesn't catch the file not found error. Am I missing something…
1
vote
1 answer

Resizing images with sharp after streaming from google cloud storage

I am trying to resize an image after streaming from google cloud storage. The streaming works fine but the resizing does not seem to work. I need to pass the image object to the resize function of sharpjs which will then resize and return the image…
1
vote
0 answers

Getting bus error when composing a lot of images with sharp

I'm trying to compose a ton of images (2300) into a transparent png using sharp. I'm trying that with the following code: await sharp({ create: { width: 256, height: 256, channels: 4, background: { r: 0, g: 0, b: 0,…
Antonio Gamiz Delgado
  • 1,871
  • 1
  • 12
  • 33
1
vote
0 answers

JS fs.createReadStream resize image before formData.append

I would like to resize and transform an image before adding to formData. I just tested a lot with e.g. the sharp library but I can't find a solution. Some code: formData.append('attachment', fs.createReadStream('sky.jpeg')); //This works fine The…
RichyTi
  • 21
  • 3
1
vote
1 answer

How to pass file name and size as query parameter in node js?

The idea is to pass a query that contends the filename and the size as the following: localhost:3000/images?filename=myImage&width=100&height=100 First I want to find out how to get the images from the image folder Second use them to resize the…
fyardlest
  • 288
  • 4
  • 17
1
vote
1 answer

Testing sharp with memfs error: [Error: Input file is missing]

I had trouble testing my code that implement sharp and memfs. I has codes that download image and cropping it to certain dimension. I use sharp to achieve the cropping. When it comes testing, I use jest and memfs. My test code has 2 parts: Download…
koonfoon
  • 433
  • 4
  • 12
1
vote
1 answer

Trying to run multiple await methods in node JS sequentially, they are running in parallel

I'm trying to combine layers of images into one image. It works fine when I have just one method to fetch the image then another and layers them together, The problem is I need to tint the image before I draw it and they have to be drawn in a…
Brian
  • 4,328
  • 13
  • 58
  • 103