Open rpelletierrefocus opened 4 years ago
To be more specific, I am just trying to reduce the dimensions by a percentage
So, on line 29 of index.ts I added '-resize 50%' which results in the code below. I am wokring with a JPEG. This does not seem to work, so I am missing something else down the line.
export const mozjpeg: IOptimizeMethod = (
input,
output,
options,
) => {
const { quality = 70 } = options
const spawnArgs = [
'-quality',
quality.toString(),
'-resize 50%',
'-outfile',
output,
input,
]
log.info('spawn', bins.mozjpeg, spawnArgs)
return spawn(bins.mozjpeg, spawnArgs, {
capture: [ 'stdout', 'stderr' ],
env: createEnv(),
}).catch(e => {
throw new Error(e.message + '\n' + e.stderr)
})
}
Just realized this method is not uing imagemagick (I had assuemed), but mozjpeg, whcih I am not familiar with, but does not seem to have a dimension (resize) option.
You could use imagemagick to resize then use mozjpeg to compress.
await spawn(bins.imagemagick) // input -> temp
await spawn(bins.mozjpeg) // temp -> output
I have just discovered there does not appear to be a way to resize the dimensions of an image? Where might I find the best place to change this? I am just going to statically set it for now and add menus/functions later.