0

I'm using imaginmin with imaginmin-jpegoptim, but it seems like jpegoptim isn't being properly utilized. My file size before is 390kb, but after conversion it's 285kb, even though I specified it to be 10kb.

Here's the code:

const imagemin =
    require("imagemin")
const imageminJpegoptim =
    require("imagemin-jpegoptim")

async function imageminJPG (
    inputs,
    output_folder,
    size
)
{
    const files =
        await imagemin(
            inputs, 
            {
                destination:
                    output_folder,
                plugins:
                [
                    imageminJpegoptim({
                        progressive:
                            false,
                        size // currently 10
                    })
                ]
            }
        )
}

Am I missing a parameter or placing them wrongly?

A. L
  • 11,695
  • 23
  • 85
  • 163
  • Even though you specify something to be a certain size, the file may not be able to be compressed down to that size. 285kb is probably the limit of the compression. – Jack Bashford Jul 03 '19 at 22:53
  • @JackBashford I've used a package called `browser-image-compression` on the frontend and it can compress the same image down to around 10kb without problems. Unless you mean its the program itself – A. L Jul 03 '19 at 22:57

0 Answers0