首页 > 解决方案 > 如何在 grunt 响应式图像任务中使用 triage 图像压缩器

问题描述

我想使用 triage 图像压缩器为我的网站压缩图像。我需要为我的 grunt 响应式图像任务中的引擎选项提供什么,以便它可以使用 triage?

我已经在 Windows 上使用 image-magickengine:"im"在我的 grunt 响应式图像任务中尝试了这个,它运行良好,切换到 ubuntu,我已经安装了 triage 图像压缩器并设置engine:"trimage"但它会产生错误Warning: Invalid render engine specified Use --force to continue.

module.exports = function(grunt) {
  require("load-grunt-tasks")(grunt);
  grunt.initConfig({
    responsive_images: {
      dev: {
        options: {
          engine: "trimage",
          sizes: [
            {
              width: 300,
              suffix: "_sm",
              quality: 60
            },
            {
              width: 500,
              suffix: "_md",
              quality: 60
            }
          ]
        },

        files: [
          {
            expand: true,
            src: ["*.{gif,jpg,png}"],
            cwd: "images_src/",
            dest: "img/"
          }
        ]
      }
    }
    grunt.registerTask("default",["responsive_images"]);
};

标签: gruntjs

解决方案


推荐阅读