Local Image Sharp

Dynamically resize, format and optimize images based on url modifiers.

Strapi Discord NPM Version Monthly download on NPM

✨ Features

Convert any uploaded images with local provider using sharp modifier. No extra configuration needed, the modifiers will be applied based on the url.

This is made by ipx

🖐 Installation

Add plugin dependency

yarn add strapi-plugin-local-image-sharp

🚚 Usage

Examples

Get original image:

http://localhost:1337/uploads/buffalo.png

Change format to webp and keep other things same as source:

http://localhost:1337/uploads/f_webp/static/buffalo.png

Keep original format png and set width to 200:

http://localhost:1337/uploads/w_200/static/buffalo.png

You can combine modifiers using a coma, for example: Resize to 200x200px using embed method and change format to webp:

http://localhost:1337/uploads/embed,f_webp,s_200x200/static/buffalo.png

Modifiers

Property Docs Example Comments
width / w Docs http://localhost:1337/uploads/width_200/buffalo.png
height / h Docs http://localhost:1337/uploads/height_200/buffalo.png
resize / s Docs http://localhost:1337/uploads/s_200x200/buffalo.png
fit Docs http://localhost:1337/uploads/s_200x200,fit_outside/buffalo.png Sets fit option for resize.
position / pos Docs http://localhost:1337/uploads/s_200x200,pos_top/buffalo.png Sets position option for resize.
trim Docs http://localhost:1337/uploads/trim_100/buffalo.png
format Docs http://localhost:1337/uploads/format_webp/buffalo.png Supported format: jpg, jpeg, png, webp, avif, gif, heif
quality / q _ http://localhost:1337/uploads/quality_50/buffalo.png Accepted values: 0 to 100
rotate Docs http://localhost:1337/uploads/rotate_45/buffalo.png
enlarge _ http://localhost:1337/uploads/enlarge,s_2000x2000/buffalo.png Allow the image to be upscaled. By default the returned image will never be larger than the source in any dimension, while preserving the requested aspect ratio.
flip Docs http://localhost:1337/uploads/flip/buffalo.png
flop Docs http://localhost:1337/uploads/flop/buffalo.png
sharpen Docs http://localhost:1337/uploads/sharpen_30/buffalo.png
median Docs http://localhost:1337/uploads/median_10/buffalo.png
gamma Docs http://localhost:1337/uploads/gamma_3/buffalo.png
negate Docs http://localhost:1337/uploads/negate/buffalo.png
normalize Docs http://localhost:1337/uploads/normalize/buffalo.png
threshold Docs http://localhost:1337/uploads/threshold_10/buffalo.png
tint Docs http://localhost:1337/uploads/tint_1098123/buffalo.png
grayscale Docs http://localhost:1337/uploads/grayscale/buffalo.png
animated http://localhost:1337/uploads/animated/buffalo.gif Experimental

Contributing

I/We are actively looking for contributors, maintainers, and others to help shape this package. As this plugins sole purpose within the Strapi community is to be used by other developers and plugin maintainers to get fast responses time.

If interested please feel free to email the lead maintainer Sacha at: [email protected] or ping stf#3254 on Discord.

License

See the LICENSE file for licensing information.

GitHub

View Github