{"id":27718065,"url":"https://github.com/semiromid/compress-images","last_synced_at":"2025-04-27T04:01:39.983Z","repository":{"id":47732685,"uuid":"109436961","full_name":"Yuriy-Svetlov/compress-images","owner":"Yuriy-Svetlov","description":"Minify size your images. Image compression with extension: jpg/jpeg, svg, png, gif. NodeJs","archived":false,"fork":false,"pushed_at":"2024-03-19T22:09:18.000Z","size":18394,"stargazers_count":604,"open_issues_count":14,"forks_count":80,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-23T06:18:56.002Z","etag":null,"topics":["compress-image","compress-images","compression","gif","image-compress","image-compression","image-minify","image-optimization","imageoptimizer","img-mini","jpeg","minifier","minify","node-module","nodejs","png","png-optimizer","pngout","pngquant","svg"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/compress-images","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yuriy-Svetlov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-03T19:51:14.000Z","updated_at":"2025-04-12T10:10:01.000Z","dependencies_parsed_at":"2024-06-18T12:37:26.125Z","dependency_job_id":"13cea4c5-fd9f-4356-8395-ad226b81724c","html_url":"https://github.com/Yuriy-Svetlov/compress-images","commit_stats":{"total_commits":242,"total_committers":9,"mean_commits":26.88888888888889,"dds":0.07438016528925617,"last_synced_commit":"faa5da24c2cc00e368ee416c454e0f093471c76f"},"previous_names":["semiromid/compress-images"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuriy-Svetlov%2Fcompress-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuriy-Svetlov%2Fcompress-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuriy-Svetlov%2Fcompress-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuriy-Svetlov%2Fcompress-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yuriy-Svetlov","download_url":"https://codeload.github.com/Yuriy-Svetlov/compress-images/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251085198,"owners_count":21533842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compress-image","compress-images","compression","gif","image-compress","image-compression","image-minify","image-optimization","imageoptimizer","img-mini","jpeg","minifier","minify","node-module","nodejs","png","png-optimizer","pngout","pngquant","svg"],"created_at":"2025-04-27T04:01:32.822Z","updated_at":"2025-04-27T04:01:39.958Z","avatar_url":"https://github.com/Yuriy-Svetlov.png","language":"C","funding_links":["https://www.paypal.com/myaccount/transfer/send"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Compress-images\n\n\n[![Build Status](https://travis-ci.org/semiromid/compress-images.svg?branch=master)](https://travis-ci.org/semiromid/compress-images)\n\n\u003e [compress-images](https://github.com/semiromid/compress-images) **Minify size your images**. Image compression with extension: jpg/jpeg, svg, png, gif.\n\n**Minify** size your images. **Image compression** with extension: **`jpg/jpeg`**, **`svg`**, **`png`**, **`gif`**. \n\n![Image](https://raw.githubusercontent.com/semiromid/compress-images/master/screenshots/1.png)\n\n\nYou can also use:\n* [imagemin](https://www.npmjs.com/package/imagemin)\n\n\n### Features\n\n\nYou can use different algorithms and methods for compressing images with many options.\n\n* For **JPG**: `jpegtran`, `mozjpeg`, `webp`, `guetzli`, `jpegRecompress`, `jpegoptim`, `tinify`;\n* For **PNG**: `pngquant`, `optipng`, `pngout`, `webp`, `pngcrush`, `tinify`;\n* For **SVG**: `svgo`;\n* For **GIF**: `gifsicle`, `giflossy`, `gif2webp`;\n\n##### Combine compression \n\n\u003e You can even minify images by using a **combination of compression algorithms**. As an example - `mozjpeg` + `jpegoptim` or `jpegtran` + `mozjpeg` or any other algorithm.\n\n\n##### Saving error log\n\n\u003e If you get an error, the error log will be saved. Default path `./log/compress-images`.\n\n\n##### Alternative configuration/algorithm for compressing images\n\n\u003e If you get an error, alternative algorithms for compressing images can be used. As an example: you want to compress images in `jpegRecompress`, but you get the error  **Unsupported color conversion request**, so an alternative algorithm to compress the images can be used, like `mozjpeg`.\n\n\n##### Detect path for saving images\nYou can specify the path to source images folder and all images in the folder will be compressed and moved to output folder.\n\n**As an example, one of many**:\n\n        INPUT ['src/img/source/**/*.{jpg,JPG,jpeg,JPEG,gif,png,svg}']\n        OUTPUT ['build/img/']\n\n##### Note\nYou should have in your path slash: `/`.\nIf you have slash `\\` it may be to replaced: `input.replace(/\\\\/g, '/')`;\n\n![Image](https://raw.githubusercontent.com/semiromid/compress-images/master/screenshots/img_structure_forder.png)\n\n\nOther useful plugins: \n* [Live Reload Browser Page](https://live-reload-browser-page.com/)\n* [Live Alert Browser Page](https://live-alert-browser-page.com/)\n* [Live HTML Validator](https://live-html-validator.com/)\n\n\n# Get started\n\n## Install\n```shell\nnpm install compress-images --save-dev\n```\n\n## Examples of how to use it\n\n#### Base example\nhttps://github.com/semiromid/compress-images/tree/master/example\n* Read the [Manual](https://github.com/semiromid/compress-images/blob/master/example/Manual.txt)\n\n\n\n#### Example 1\n```javascript\n\nconst compress_images = require(\"compress-images\"),\n  INPUT_path_to_your_images,\n  OUTPUT_path;\n\nINPUT_path_to_your_images = \"src/img/**/*.{jpg,JPG,jpeg,JPEG,png,svg,gif}\";\nOUTPUT_path = \"build/img/\";\n\ncompress_images(INPUT_path_to_your_images, OUTPUT_path, { compress_force: false, statistic: true, autoupdate: true }, false,\n                { jpg: { engine: \"mozjpeg\", command: [\"-quality\", \"60\"] } },\n                { png: { engine: \"pngquant\", command: [\"--quality=20-50\", \"-o\"] } },\n                { svg: { engine: \"svgo\", command: \"--multipass\" } },\n                { gif: { engine: \"gifsicle\", command: [\"--colors\", \"64\", \"--use-col=web\"] } },\n  function (error, completed, statistic) {\n    console.log(\"-------------\");\n    console.log(error);\n    console.log(completed);\n    console.log(statistic);\n    console.log(\"-------------\");\n  }\n);\n```\n\n#### Example 2\n```javascript\nconst compress_images = require(\"compress-images\");\n\nfunction MyFun() {\n  compress_images(\n    \"src/img/**/*.{jpg,JPG,jpeg,JPEG,png,svg,gif}\",\n    \"build/img/\",\n    { compress_force: false, statistic: true, autoupdate: true },\n    false,\n    { jpg: { engine: \"mozjpeg\", command: [\"-quality\", \"60\"] } },\n    { png: { engine: \"pngquant\", command: [\"--quality=20-50\", \"-o\"] } },\n    { svg: { engine: \"svgo\", command: \"--multipass\" } },\n    {\n      gif: { engine: \"gifsicle\", command: [\"--colors\", \"64\", \"--use-col=web\"] },\n    },\n    function (err, completed) {\n      if (completed === true) {\n        // Doing something.\n      }\n    }\n  );\n}\n```\n\n\n#### Example 3\n```javascript\nconst compress_images = require('compress-images');\n\n// We will be compressing images [jpg] with two algorithms, [webp] and [jpg];\n\n//[jpg] ---to---\u003e [webp]\ncompress_images(\n  \"src/img/**/*.{jpg,JPG,jpeg,JPEG}\",\n  \"build/img/\",\n  { compress_force: false, statistic: true, autoupdate: true },\n  false,\n  { jpg: { engine: \"webp\", command: false } },\n  { png: { engine: false, command: false } },\n  { svg: { engine: false, command: false } },\n  { gif: { engine: false, command: false } },\n  function (err) {\n    if (err === null) {\n      //[jpg] ---to---\u003e [jpg(jpegtran)] WARNING!!! autoupdate  - recommended to turn this off, it's not needed here - autoupdate: false\n      compress_images(\n        \"src/img/**/*.{jpg,JPG,jpeg,JPEG}\",\n        \"build/img/\",\n        { compress_force: false, statistic: true, autoupdate: false },\n        false,\n        { jpg: { engine: \"jpegtran\", command: false } },\n        { png: { engine: false, command: false } },\n        { svg: { engine: false, command: false } },\n        { gif: { engine: false, command: false } },\n        function () {}\n      );\n    } else {\n      console.error(err);\n    }\n  }\n);\n```\n\n\n\n#### Example 4\n```javascript\nconst compress_images = require('compress-images');\n\n// Combine compressing images [jpg] with two different algorithms, [jpegtran] and [mozjpeg];\n//[jpg] ---to---\u003e [jpg(jpegtran)]\ncompress_images(\n  \"src/img/source/**/*.{jpg,JPG,jpeg,JPEG}\",\n  \"src/img/combination/\",\n  { compress_force: false, statistic: true, autoupdate: true },\n  false,\n  {\n    jpg: {\n      engine: \"jpegtran\",\n      command: [\"-trim\", \"-progressive\", \"-copy\", \"none\", \"-optimize\"],\n    },\n  },\n  { png: { engine: false, command: false } },\n  { svg: { engine: false, command: false } },\n  { gif: { engine: false, command: false } },\n  function () {\n    //[jpg(jpegtran)] ---to---\u003e [jpg(mozjpeg)] WARNING!!! autoupdate  - recommended to turn this off, it's not needed here - autoupdate: false\n    //----------------\n    compress_images(\n      \"src/img/combination/**/*.{jpg,JPG,jpeg,JPEG}\",\n      \"build/img/\",\n      { compress_force: false, statistic: true, autoupdate: false },\n      false,\n      { jpg: { engine: \"mozjpeg\", command: [\"-quality\", \"75\"] } },\n      { png: { engine: false, command: false } },\n      { svg: { engine: false, command: false } },\n      { gif: { engine: false, command: false } },\n      function () {}\n    );\n    //----------------\n  }\n);\n```\n\n\n\n#### Example 5\n```javascript\nconst compress_images = require('compress-images');\n\n//[jpg+gif+png+svg] ---to---\u003e [jpg(webp)+gif(gifsicle)+png(webp)+svg(svgo)]\ncompress_images('src/img/source/**/*.{jpg,JPG,jpeg,JPEG,gif,png,svg}', 'build/img/', {compress_force: false, statistic: true, autoupdate: true}, false,\n                                            {jpg: {engine: 'webp', command: false}},\n                                            {png: {engine: 'webp', command: false}},\n                                            {svg: {engine: 'svgo', command: false}},\n                                            {gif: {engine: 'gifsicle', command: ['--colors', '64', '--use-col=web']}}, function(){\n      //-------------------------------------------------                                    \n      //[jpg] ---to---\u003e [jpg(jpegtran)] WARNING!!! autoupdate  - recommended to turn this off, it's not needed here - autoupdate: false\n      compress_images('src/img/source/**/*.{jpg,JPG,jpeg,JPEG}', 'src/img/combine/', {compress_force: false, statistic: true, autoupdate: false}, false,\n                                                      {jpg: {engine: 'jpegtran', command: ['-trim', '-progressive', '-copy', 'none', '-optimize']}},\n                                                      {png: {engine: false, command: false}},\n                                                      {svg: {engine: false, command: false}},\n                                                      {gif: {engine: false, command: false}}, function(){\n            //[jpg(jpegtran)] ---to---\u003e [jpg(mozjpeg)] WARNING!!! autoupdate  - recommended to turn this off, it's not needed here - autoupdate: false\n            compress_images('src/img/combine/**/*.{jpg,JPG,jpeg,JPEG}', 'build/img/', {compress_force: false, statistic: true, autoupdate: false}, false,\n                                                            {jpg: {engine: 'mozjpeg', command: ['-quality', '75']}},\n                                                            {png: {engine: false, command: false}},\n                                                            {svg: {engine: false, command: false}},\n                                                            {gif: {engine: false, command: false}}, function(){\n                  //[png] ---to---\u003e [png(pngquant)] WARNING!!! autoupdate  - recommended to turn this off, it's not needed here - autoupdate: false\n                  compress_images('src/img/source/**/*.png', 'build/img/', {compress_force: false, statistic: true, autoupdate: false}, false,\n                                                                  {jpg: {engine: false, command: false}},\n                                                                  {png: {engine: 'pngquant', command: ['--quality=30-60', '-o']}},\n                                                                  {svg: {engine: false, command: false}},\n                                                                  {gif: {engine: false, command: false}}, function(){                                                      \n                  }); \n            });                                      \n      });\n      //-------------------------------------------------\n});\n```\n\n\n\n#### Example 6\nSometimes you could get errors, and then use alternative configuration \"compress-images\".\nAs an example, one of many:\n\n1. If you get an error from 'jpegRecompress', for example, the error \"Unsupported color conversion request\". In this case, an alternative image compression algorithm will be used.\n\n2. An error log will be created at path './log/lib/compress-images'.\n\n3. The algorithm 'mozjpeg' will attempt to be used instead.\n\n```javascript\n    const \n    compress_images = require('compress-images'),\n    INPUT_path_to_your_images = 'src/**/*.{jpg,JPG,jpeg,JPEG,png,svg,gif}',\n    OUTPUT_path = 'build/';\n    \n    compress_images(INPUT_path_to_your_images, OUTPUT_path, {compress_force: false, statistic: true, autoupdate: true, pathLog: './log/lib/compress-images'}, false,\n                                                {jpg: {engine: 'jpegRecompress', command: ['--quality', 'high', '--min', '60']}},\n                                                {png: {engine: 'pngquant', command: ['--quality=20-50', '-o']}},\n                                                {svg: {engine: 'svgo', command: '--multipass'}},\n                                                {gif: {engine: 'gifsicle', command: ['--colors', '64', '--use-col=web']}}, function(err, completed){\n            if(err !== null){\n                //---------------------------------------\n                //if you get an ERROR from 'jpegRecompress' ---\u003e We can use alternate config of compression\n                //---------------------------------------\n                if(err.engine === 'jpegRecompress'){\n                    compress_images(err.input, err.output, {compress_force: false, statistic: true, autoupdate: true}, false,\n                                                                {jpg: {engine: 'mozjpeg', command: ['-quality', '60']}},\n                                                                {png: {engine: false, command: false}},\n                                                                {svg: {engine: false, command: false}},\n                                                                {gif: {engine: false, command: false}}, function(err){\n                            if(err !== null){\n                                //Alternative config of compression\n\n                            }                                       \n                    });\n                }\n                //---------------------------------------\n\n            }                                       \n\n    });\n```\n\n#### Example 7\n\nCompressing an image in the same folder (currently this only works with 'pngquant')\n\n```javascript\n    const \n    compress_images = require('compress-images'),\n    fs = require('fs'),\n    INPUT_path_to_your_images = 'src/img/**/!(*-min).png',\n    OUTPUT_path = 'src/img/';\n    \n    compress_images(INPUT_path_to_your_images, OUTPUT_path, {compress_force: true, statistic: false, autoupdate: true}, false,\n                                                {jpg: {engine: false, command: false}},\n                                                {png: {engine: 'pngquant', command: ['--quality=20-50', '--ext=-min.png', '--force']}},\n                                                {svg: {engine: false, command: false}},\n                                                {gif: {engine: false, command: false}}, function(err, completed, statistic){\n        if(err === null){\n            fs.unlink(statistic.input, (err) =\u003e {\n                if (err) throw err;\n                console.log('successfully compressed and deleted '+statistic.input);\n            });\n        }\n    });\n```\n\n```html\n    \u003cpicture\u003e\n        \u003csource type=\"image/webp\" srcset=\"//hostname/build/img/art/1/chat.webp\"\u003e\n        \u003cimg width=\"700\" height=\"922\" alt=\"test\" src=\"//hostname/build/img/art/1/chat.jpg\"\u003e\n    \u003c/picture\u003e\n```\n\n## API\n\n**`compress_images`**(*`input`*, *`output`*, *`option`*, *`globoption`*, *`enginejpg`*, *`enginepng`*, *`enginesvg`*, *`enginegif`*, *`callback`*)\n+ **input** (type:string): Path to source image or images;  \u003cbr /\u003e\n        Example:    \u003cbr /\u003e\n        1. `'src/img/**/*.{jpg,JPG,jpeg,JPEG,png,svg,gif}'`;  \u003cbr /\u003e\n        2. `'src/img/**/*.jpg'`;  \u003cbr /\u003e\n        3. `'src/img/*.jpg'`;  \u003cbr /\u003e\n        4. `'src/img/myimagename.jpg'`;  \n\n+ **output** (type:string): Path to compress images;  \u003cbr /\u003e\n            Example:   \u003cbr /\u003e\n            1. `'build/img/'`;  \u003cbr /\u003e\n\n+ **option** (type:plainObject): Options module\\`s «compress-images»; \n    + **compress_force** (type:boolean): Force compress images already compressed images *`true`* or *`false`*;\n    + **statistic** (type:boolean): show image compression statistics *`true`* or *`false`*;\n    + **pathLog** (type:string): Path to log file. Default is `./log/compress-images`;\n    + **autoupdate** (type:boolean): Auto-update module «compress_images» to the latest version *`true`* or *`false`*;  \u003cbr /\u003e\n            Example:   \u003cbr /\u003e\n            1. `{compress_force: false, statistic: true, autoupdate: true}`;  \n\n+  **globoption** (type:boolean|other): Options  module\\`s [glob](https://www.npmjs.com/package/glob). Also you can set `false`;\n\n+  **enginejpg** (type:plainObject): Engine for compressing **jpeg** and options compress. Key to be `jpg`;\n    + **engine** (type:string): Engine for compressing jpeg. Possible values:\n*`jpegtran`*,*`mozjpeg`*, *`webp`*, *`guetzli`*, *`jpegRecompress`*, *`jpegoptim`*, *`tinify`*;\n    + **command** (type:boolean|array): Options for compression. Can be `false` or commands array.\n        + For **jpegtran** - `['-trim', '-progressive', '-copy', 'none', '-optimize']` in details; [jpegtran](https://libjpeg-turbo.org/);\n        + For **mozjpeg** - `['-quality', '10']` in details [mozjpeg](https://github.com/mozilla/mozjpeg/);\n        + For **webp** - `['-q', '60']` in details [webp](https://developers.google.com/speed/webp/);\n        + For **guetzli** - `['--quality', '84']` (Very long compresses on Win 8.1 [https://github.com/google/guetzli/issues/238](https://github.com/google/guetzli/issues/238)) in details [guetzli](https://github.com/google/guetzli/);\n        To use guetzli you must `npm install guetzli --save`, this library does not work properly on some OS and platforms.\n        + For **jpegRecompress** - `['--quality', 'high', '--min', '60']` in details [jpegRecompress](https://github.com/danielgtaylor/jpeg-archive/);\n        + For **jpegoptim** - `['--all-progressive', '-d']` \n        To use jpegoptim you must `npm install jpegoptim-bin --save`, this library does not work properly on some OS and platforms.\n        from https://github.com/imagemin/jpegoptim-bin\n        **Issues!**\n        May be a problems with installation and use on Win 7 x32 and maybe other OS: \n        [compress-images - issues/21](https://github.com/semiromid/compress-images/issues/21)\n        **Caution!** if do not specify `'-d'` all images will be compressed in the source folder and will be replaced. \n        For Windows x32 and x63 also, you can use [https://github.com/vikas5914/jpegoptim-win](https://github.com/vikas5914/jpegoptim-win). Copy jpegoptim-32.exe and replace and rename in \"node_modules\\jpegoptim-bin\\vendor\\jpegoptim.exe\"\n          \n        + For **tinify** - `['copyright', 'creation', 'location']` In details [tinify](https://tinypng.com/developers/reference/nodejs/);\n    + **key** (type:string): Key used for engine **tinify**.  In details; [tinify](https://tinypng.com/developers/reference/nodejs/);  \u003cbr /\u003e\n            Example:  \u003cbr /\u003e \n            1. `{jpg: {engine: 'mozjpeg', command: ['-quality', '60']}`;  \u003cbr /\u003e\n            2. `{jpg: {engine: 'tinify', key: \"sefdfdcv335fxgfe3qw\", command: ['copyright', 'creation', 'location']}}`;  \u003cbr /\u003e\n            3. `{jpg: {engine: 'tinify', key: \"sefdfdcv335fxgfe3qw\", command: false}}`;    \n    \n+  **enginepng** (type:plainObject): Engine for compressing **png** and options for compression. Key to be `png`;\n    + **engine** (type:string): Engine for compressing png. Possible values:\n*`pngquant`*,*`optipng`*, *`pngout`*, *`webp`*, *`pngcrush`*, *`tinify`*;\n    + **command** (type:boolean|array): Options for compression. Can be `false` or commands array.\n        + For **pngquant** - `['--quality=20-50', '-o']` If you want to compress in the same folder, as example: ['--quality=20-50', '--ext=.png', '--force']. To use this library you need to install it manually. It does not work properly on some OS (Win 7 x32 and maybe other). `npm install pngquant-bin --save` \n        Quality should be in format min-max where min and max are numbers in range 0-100. Can be problems with cyrillic filename [issues/317](https://github.com/kornelski/pngquant/issues/317) \n        In details: \n        [pngquant](https://pngquant.org/) and \n        [pngquant-bin - wrapper](https://github.com/imagemin/pngquant-bin)\n        + For **optipng** - To use this library you need to install it manually. \n        It does not work properly on some OS (Win 7 x32 and maybe other). `npm install --save optipng-bin` in details [optipng-bin - wrapper](https://github.com/imagemin/optipng-bin)\n        and [optipng](http://optipng.sourceforge.net/);\n        + For **pngout** - in details [pngout](http://advsys.net/ken/util/pngout.htm);\n        + For **webp** - `['-q', '60']` in details [webp](https://developers.google.com/speed/webp/);\n        + For **pngcrush** (It does not work properly on some OS) - `['-reduce', '-brute']` in details [pngcrush](https://pmt.sourceforge.io/pngcrush/);\n        + For **tinify** - `['copyright', 'creation', 'location']` in details [tinify](https://tinypng.com/developers/reference/nodejs/);\n    + **key** (type:string): Key used for engine **tinify**.  In details; [tinify](https://tinypng.com/developers/reference/nodejs/);  \u003cbr /\u003e\n            Example:  \u003cbr /\u003e \n            1. `{png: {engine: 'webp', command: ['-q', '100']}`;  \u003cbr /\u003e\n            2. `{png: {engine: 'tinify', key: \"sefdfdcv335fxgfe3qw\", command: ['copyright', 'creation', 'location']}}`;  \u003cbr /\u003e\n            3. `{png: {engine: 'optipng', command: false}}`;\n\n\n+  **enginesvg** (type:plainObject): Engine for compressing **svg** and options for compression. Key to be `svg`;\n    + **engine** (type:string): Engine for compressing svg. Possible values:\n*`svgo`*;    \n    + **command** (type:string): Options for compression. Can be `false` or commands type string.\n        + For **svgo** - `'--multipass'` in details [svgo](https://www.npmjs.com/package/svgo/);  \u003cbr /\u003e\n                Example:  \u003cbr /\u003e\n                1. `{svg: {engine: 'svgo', command: '--multipass'}`;  \u003cbr /\u003e\n                2. `{svg: {engine: 'svgo', command: false}}`;\n\n\n+  **enginegif** (type:plainObject): Engine for compressing **gif** and options for compression. Key to be `gif`;\n    + **engine** (type:string): Engine for compressing gif. Possible values:\n*`gifsicle`*, *`giflossy`*, *`gif2webp`*;  \n    + **command** (type:boolean|array): Options for compression. Can be `false` or commands type array.\n        + For **gifsicle** - To use this library you need to install it manually.\nIt does not work properly on some OS. `npm install gifsicle --save`. \n        Example options:  \n        `['--colors', '64', '--use-col=web']` or `['--optimize']` In details [gifsicle](http://www.lcdf.org/gifsicle/);\n        + For **giflossy** - (For Linux x64 and Mac OS X) `['--lossy=80']` In details [giflossy](http://www.lcdf.org/gifsicle/);\n        + For **gif2webp** - `['-f', '80', '-mixed', '-q', '30', '-m', '2']` in details [gif2webp](https://developers.google.com/speed/webp/docs/gif2webp);    \u003cbr /\u003e\n                Example:  \u003cbr /\u003e\n                1. `{gif: {engine: 'gifsicle', command: ['--colors', '64', '--use-col=web', '--scale', ' 0.8']}}`;  \u003cbr /\u003e\n                2. `{gif: {engine: 'giflossy', command: false}}`;  \u003cbr /\u003e\n                3. `{gif: {engine: 'gif2webp', command: ['-f', '80', '-mixed', '-q', '30', '-m', '2']}}`;\n                \n+ **callback** (err, completed, statistic): \nreturns: \n    +  **err** (type:json object|null)  \n        + engine - The name of the algorithm engine \n        + input - The path to the input image \n        + output - The path to the output image\n    + **completed** (type:boolean)\n        + `true` - result completed.\n        + `false` - result not completed.\n    + **statistic** (type:json object)\n        + `input`\n        + `path_out_new`\n        + `algorithm`\n        + `size_in`\n        + `size_output`\n        + `percent`\n        + `err`        \n\u003cbr /\u003e\n\n\n## How to use promise API \n\n\n#### Example 1\n\n\n```javascript\n    const { compress } = require('compress-images/promise');\n    const INPUT_path_to_your_images = 'src/img/**/*.{jpg,JPG,jpeg,JPEG,png}';\n    const OUTPUT_path = 'build/img/';\n\n    const processImages = async () =\u003e {\n        const result = await compress({\n            source: INPUT_path_to_your_images,\n            destination: OUTPUT_path,\n            enginesSetup: {\n                jpg: { engine: 'mozjpeg', command: ['-quality', '60']},\n                png: { engine: 'pngquant', command: ['--quality=20-50', '-o']},\n            }\n        });\n\n        const { statistics, errors } = result;\n        // statistics - all processed images list\n        // errors - all errros happened list\n    };\n\n    processImages();\n```\n\n#### Example 2\nUsing `onProgress`\n\n```javascript\n    const { compress } = require('compress-images/promise');\n    const INPUT_path_to_your_images = 'src/img/**/*.{jpg,JPG,jpeg,JPEG,png}';\n    const OUTPUT_path = 'build/img/';\n\n    const processImages = async (onProgress) =\u003e {\n        const result = await compress({\n            source: INPUT_path_to_your_images,\n            destination: OUTPUT_path,\n            onProgress,\n            enginesSetup: {\n                jpg: { engine: 'mozjpeg', command: ['-quality', '60']},\n                png: { engine: 'pngquant', command: ['--quality=20-50', '-o']},\n            }\n        });\n\n        const { statistics, errors } = result;\n        // statistics - all processed images list\n        // errors - all errros happened list\n    };\n\n    processImages((error, statistic, completed) =\u003e {\n        if (error) {\n            console.log('Error happen while processing file');\n            console.log(error);\n            return;\n        }\n\n        console.log('Sucefully processed file');\n\n        console.log(statistic)\n    });\n```\n\n## Promised API\n\n**`promise/compress`**(*`params`*)\n\n+ **params** (type:plainObject): Module options;\n    + **source** (type:string): **input**, see above;\n    + **destination** (type:string): **output**, see above;\n    + **enginesSetup** (type:plainObject):  Engines setup mapping, only needed ones, for example: `{ jpg: \u003cenginejpg\u003e, png: \u003cenginepng\u003e }`, see details above;\n    + (optional) **params** (type:plainObject): Options module\\`s «compress-images», see **option** above;\n    + (optional) **globOptions** (type:boolean|other): see **globoption** above;\n    + (optional) **onProgress** (err, statistic, completed): see **callback** above\n\n+ returns **Promise** with object:\n    + **statistics** (type:**statistic[]**), see above;\n    + **errors** (type:**err[]**), see above;\n\n_______________________\n\n### Donate\n![Image](https://raw.githubusercontent.com/semiromid/compress-images/master/screenshots/health-care.png)\nIf this is a useful thing for you, support the project.\n\n **PayPal** | [https://www.paypal.com/myaccount/transfer/send](https://www.paypal.com/myaccount/transfer/send) **`startpascal1@mail.ru`**\n \n **Visa Card** | **`4731 1856 1426 6432`** First name and Last name: `SEMINA TAMARA` or `SEMINA TAMARA PETROVNA`\n \n **Payeer** | [payeer.com](payeer.com) No.[**`P77135727`**]\n \n **PaYoneer** | [https://www.payoneer.com](https://www.payoneer.com) **`startpascal1@mail.ru`**\n \n_______________________\n\n\n## Related\ngif2webp [https://developers.google.com/speed/webp/docs/gif2webp](https://developers.google.com/speed/webp/docs/gif2webp) author is Google;\n\nNode package giflossy [https://www.npmjs.com/package/giflossy](https://www.npmjs.com/package/giflossy) Author is Jihchi;\n\ngifsicle and giflossy [http://www.lcdf.org/gifsicle/](http://www.lcdf.org/gifsicle/) author is Eddie Kohler;\n\ngifsicle-bin [https://github.com/imagemin/gifsicle-bin](https://github.com/imagemin/gifsicle-bin) author is Kevva;\n\nsvgo [https://www.npmjs.com/package/svgo](https://www.npmjs.com/package/svgo) author is Greli;\n\npngcrush [https://pmt.sourceforge.io/pngcrush/](https://pmt.sourceforge.io/pngcrush/) author is Glenn Randers-Pehrson;\n\npngcrush-bin [https://github.com/imagemin/pngcrush-bin](https://github.com/imagemin/pngcrush-bin) author is Kevva;\n\nwebp [https://developers.google.com/speed/webp/](https://developers.google.com/speed/webp/) author is Google;\n\npngout [http://advsys.net/ken/util/pngout.htm](http://advsys.net/ken/util/pngout.htm) author is Kerry Watson, with updates by Ken Silverman and Matthew Fearnley;\n\npngout-bin [https://github.com/imagemin/pngout-bin](https://github.com/imagemin/pngout-bin) author is 1000ch;\n\npngquant [https://pngquant.org/](https://pngquant.org/) author is  Kornel Lesiński and contributors. It's based on code by Greg Roelofs and Jef Poskanzer;\n\npngquant-bin [https://github.com/imagemin/pngquant-bin](https://github.com/imagemin/pngquant-bin) author is Kevva;\n\ntinypng [https://tinypng.com/developers/reference/nodejs](https://tinypng.com/developers/reference/nodejs) author is Voormedia;\n\ntinyjpg [https://tinyjpg.com/](https://tinyjpg.com/) author is Voormedia;\n\njpegoptim [https://github.com/tjko/jpegoptim](https://github.com/tjko/jpegoptim) author is Tjko;\n\njpegoptim-bin [https://github.com/imagemin/jpegoptim-bin](https://github.com/imagemin/jpegoptim-bin) author is 1000ch;\n\njpeg-archive [https://github.com/danielgtaylor/jpeg-archive](https://github.com/danielgtaylor/jpeg-archive) author is Danielgtaylor;\n\njpeg-recompress-bin [https://github.com/imagemin/jpeg-recompress-bin](https://github.com/imagemin/jpeg-recompress-bin) author is 1000ch;\n\nguetzli [https://github.com/google/guetzli](https://github.com/google/guetzli) author is Google;\n\nguetzli-bin [https://github.com/imagemin/guetzli-bin](https://github.com/imagemin/guetzli-bin) author is 1000ch;\n\nmozjpeg-bin [https://github.com/imagemin/mozjpeg-bin](https://github.com/imagemin/mozjpeg-bin) author is 1000ch;\n\nmozjpeg [https://github.com/mozilla/mozjpeg](https://github.com/mozilla/mozjpeg) author is Pornel;\n\njpegtran-bin [https://github.com/imagemin/jpegtran-bin](https://github.com/imagemin/jpegtran-bin) author is 1000ch;\n\nlibjpeg-turbo [https://libjpeg-turbo.org/](https://libjpeg-turbo.org/) author is Dcommander;\n\nVectors [https://www.flaticon.com/authors/vectors-market](https://www.flaticon.com/authors/vectors-market) author is Vectors Market;\n\ncolors [https://www.npmjs.com/package/colors](https://www.npmjs.com/package/colors) author is Marak;\n\nglob [https://www.npmjs.com/package/glob](https://www.npmjs.com/package/glob) author is Isaacs;\n\n\nmkdirp [https://www.npmjs.com/package/mkdirp](https://www.npmjs.com/package/mkdirp) author is Substack;\n\n\nbytes [https://www.npmjs.com/package/bytes](https://www.npmjs.com/package/bytes) author is Dougwilson;\n\n\nРазработка сайтов [Веб-студия Харьков](https://web-studio.kh.ua)\n\n\n## Bugs\n  * github - [https://github.com/semiromid/compress-images/issues](https://github.com/semiromid/compress-images/issues) \n\n## Author\nSEMINA TAMARA\n\n\n## License\nMIT License\n\nCopyright (c) 2017 TAMARA SEMINA\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemiromid%2Fcompress-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsemiromid%2Fcompress-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemiromid%2Fcompress-images/lists"}