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

Bulk Convert Entire Folder of Images with sharp

I have a project where I need to bulk convert large amounts of .png files to .jpgs, with some control over compression quality. Using the node module sharp works like a charm on individual files, e.g.: const sharp =…
jimiayler
  • 674
  • 2
  • 11
  • 27
4
votes
2 answers

[Node.js, sharp]: Make text take up 100% of SVG width

I am using the sharp image library to add text labels to an image. The only way to add text to an image using sharp is by creating an svg and using the composite function to apply it onto the source image. let width = 100; let height = 25; let label…
No stupid questions
  • 425
  • 1
  • 11
  • 31
4
votes
2 answers

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 cors = require('cors'); const formidable =…
Rahul Ahire
  • 161
  • 3
  • 15
4
votes
1 answer

self signed certificate in certificate chain while runnig npm i for a strapi project

I am trying to setup a Strapi project on my corporate laptop. When I run the command npm i it installs the some modules and when it finally reaches > sharp@0.26.2 install C:\\Documents\Office\km-service\node_modules\sharp > (node…
Aditya Priyam
  • 156
  • 1
  • 11
4
votes
4 answers

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 error is: Provided module can't be loaded. …
James Tyner
  • 61
  • 1
  • 7
4
votes
2 answers

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 sharp to create these compositions with this…
Francesco
  • 429
  • 4
  • 12
4
votes
2 answers

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 not work. const process = await…
Shan
  • 180
  • 1
  • 2
  • 13
4
votes
4 answers

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. But, lambda upload zip size is more and more larger. so, I…
hyundeock
  • 445
  • 1
  • 6
  • 15
4
votes
5 answers

Multer-S3 with sharp upload and resize

I've been able to upload to s3 an image file using multer-s3 library but now I'm trying to add the sharp library to resize and rotate but can't figure out where or how it needs to go. This is my current code that works for uploading: var options =…
Andres
  • 2,013
  • 6
  • 42
  • 67
4
votes
2 answers

Error sharp.resize(...).max is not a function while resizing image with Sharp

I'm trying to resize an image with sharp, version is "sharp": "^0.23.0". I used the sample code from functions-samples. My code is here thumbnailGeneratorSharp: async (object) => { const fileBucket = object.bucket; // The Storage bucket that…
Shahrear Bin Amin
  • 1,075
  • 13
  • 31
4
votes
2 answers

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 KB and with Sharp 1.3 MB. Some recommendation to…
NAG
  • 341
  • 6
  • 29
4
votes
1 answer

Using Sharp to compress image size without changing aspect ratio of the image

I have an aws image file and Iam compressing the image using sharp , but after compressing, the file size is increasing hugely . In my case I have an image size of 6.5MB , which after compressing it is becoming 19.5MB. The following is my code…
Shaik Nizamuddin
  • 589
  • 1
  • 7
  • 23
4
votes
2 answers

Node JS Sharp - Maintain SVG Font When Converting To JPG

I am using the sharp library to create dynamic JPEG license plate images. Basically, I have a PNG that is a vanity license plate with no numbers. Then I create an svg in code like so const svg = new Buffer( `
DevShadow
  • 759
  • 2
  • 8
  • 27
4
votes
2 answers

How to run Sharp transform on readable http stream and write toFile

This question is about the node Sharp library http://sharp.pixelplumbing.com/en/stable/api-input/ Documentation for the constructor says that it can read image data from a stream if you pipe it into the sharp object. "JPEG, PNG, WebP, GIF, SVG, TIFF…
androidguy
  • 3,005
  • 2
  • 27
  • 38
4
votes
1 answer

Why are my resized images alway blurry?

I'm using node.js and sharp to resize images that my users upload. They are always blurry. I have no idea why. Here is my code: var sharp = require("sharp"); sharp(file.path) .resize(width, height).max() .toFormat('png') …
joeygrimes
  • 137
  • 2
  • 12