Node.js Grunt将.png转换为.jpg文件

Node.js Grunt将.png转换为.jpg文件,node.js,web,gruntjs,png,jpeg,Node.js,Web,Gruntjs,Png,Jpeg,我试图在grunt中找到任何东西将我的.png文件转换为.jpg文件,但我只能找到.png压缩或将.pngs和.jpgs转换为.webp 有人知道怎么做吗?我将Node.js与AngularJS和Grunt一起使用 编辑 grunt.registerMultiTask('pngToJpg', 'Convert PNG files to JPG format', function() { const imagemin = require('imagemin');

我试图在grunt中找到任何东西将我的
.png
文件转换为
.jpg
文件,但我只能找到
.png
压缩或将
.pngs
.jpgs
转换为
.webp

有人知道怎么做吗?我将Node.js与AngularJS和Grunt一起使用

编辑

grunt.registerMultiTask('pngToJpg', 'Convert PNG files to JPG format', function() {

        const imagemin = require('imagemin');
        const pngToJpeg = require('png-to-jpeg');

        grunt.log.write('Loaded dependencies...').ok();

        imagemin(['images/*.png'], 'build/images', {
            plugins: [
                pngToJpeg({quality: 90})
            ]
        }).then((files) => {
            // Please keep in mind that all files now have the wrong extension
            // You might want to change them manually
            grunt.log.write('Loaded dependencies...').ok();
        });
    });

我认为grunt网站上没有这样的grunt插件,但是你可以从npmjs.com在下面的URL安装png到jpeg转换器

并且可以将它们作为自定义任务添加到
grunfile.js


希望这有帮助

谢谢,我不太熟悉grunt中的自定义任务。我试着像上面那样做,但没有成功。你能帮我一点忙吗?