0

I am using openresty Nginx to server images, how can I add avif support for the same. currently, image resizing is done via a Lua script. I found a JS solution here

import * as sharp from 'sharp';

sharp('input.png')
 .toFormat('heif', { quality: 30, compression: 'av1' })
 .toFile('output.avif')
 .then(info => console.log(info));

Can't find any lua script for the same.

Revision:

my current lua script only resize the image to the requested size

local magick = require("magick")
magick.thumb(source_fname, size, dest_fname)

I want a lua script to convert any requested image to avif. JS solution works but can't integrate that in the openresty nginx server

Vipul
  • 1
  • 1
  • Since you don't show your existing Lua script, we can't tell you what a good solution would be without changing everything. I'm also not quite sure what exactly you want. Your JS solution only seems to convert a PNG image to AVIF, which is not what you seem to be asking about. – DarkWiiPlayer Jan 20 '21 at 15:19
  • I want to convert any image to avif using lua the existing lua script only resize the image for the desired size using magick local magick = require("magick") magick.thumb(source_fname, size, dest_fname) – Vipul Jan 21 '21 at 05:17
  • I don't know if magick can do this, but libvips seems to be able to save and load avif images. – DarkWiiPlayer Jan 21 '21 at 07:53
  • I need something that will convert the image like the JS script – Vipul Jan 21 '21 at 09:28

0 Answers0