├── .editorconfig ├── .gitattributes ├── .gitignore ├── .npmrc ├── changelog.md ├── code-of-conduct.md ├── images ├── JAMstack.jpg └── VSCode.jpg ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # NPM # 2 | ########## 3 | # Ignore all directories called node_modules in current folder and any subfolders. 4 | node_modules/ 5 | /node_modules/ 6 | 7 | # Packages # 8 | ############ 9 | *.7z 10 | *.dmg 11 | *.gz 12 | *.bz2 13 | *.iso 14 | *.jar 15 | *.rar 16 | *.tar 17 | *.zip 18 | *.tgz 19 | *.map 20 | 21 | # Logs and databases # 22 | ###################### 23 | *.log 24 | *.sql 25 | *.env 26 | 27 | # OS generated files # 28 | ###################### 29 | **.DS_Store* 30 | ehthumbs.db 31 | Icon? 32 | Thumbs.db 33 | ._* 34 | 35 | # Vim generated files # 36 | ###################### 37 | *.un~ 38 | 39 | # SASS # 40 | ########## 41 | **/.sass-cache 42 | **/.sass-cache/* 43 | **/.map 44 | 45 | # Composer # 46 | ########## 47 | !assets/js/vendor/ 48 | wpcs/ 49 | /vendor/ 50 | 51 | # Bower # 52 | ########## 53 | assets/bower_components/* 54 | 55 | # Codekit # 56 | ########## 57 | /codekit-config.json 58 | *.codekit 59 | **.codekit-cache/* 60 | 61 | # Compiled Files and Build Dirs # 62 | ########## 63 | /README.html 64 | 65 | # PhpStrom Project Files # 66 | .idea/ 67 | library/vendors/composer 68 | assets/img/.DS_Store 69 | 70 | # No lock files. 71 | package-lock.json 72 | yarn.lock 73 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | All notable changes in this project's [released versions](../../releases) are documented in this file. 4 | 5 | > [**Support my work**][sponsor]: If you or your company use any of my projects or like what I’m doing then consider [backing me][sponsor]. I'm in this for the long run. An open-source developer advocate. 6 | 7 | [![Sponsor Awais](https://img.shields.io/badge/-Sponsor%20Awais%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://github.com/AhmadAwais/sponsor/?utm_source=FOSS) [![Node.js CLI Automation](https://img.shields.io/badge/-NodeCLI.com%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://NodeCLI.com/?utm_source=FOSS) 8 | [![VSCode](https://img.shields.io/badge/-VSCode.pro%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS) 9 | [![Follow @MrAhmadAwais on Twitter](https://img.shields.io/twitter/follow/mrahmadawais.svg?style=social&label=Follow%20@MrAhmadAwais)](https://twitter.com/mrahmadawais/) 10 | 11 |
12 | 13 | I have released a video course to help you build Node.js CLIs for Automation

14 | 15 |
NodeCLI.com
→ 16 | 17 |
18 | 19 | [![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) 20 | 21 | **CHANGELOG KEY**: `📦 NEW`, `👌 IMPROVE`, `🐛 FIX`, `📖 DOC`, `🚀 RELEASE`, `🤖 TEST`, and `‼️ BREAKING`. 22 | 23 | 24 | 25 | > _I use [Emoji-log](https://github.com/ahmadawais/Emoji-Log), you should try it and simplify your git commits._ 26 | 27 | 28 | 29 |
30 | 31 | [![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) 32 | 33 |
34 | 35 | ### RELEASE: [v1.1.2](https://github.com/ahmadawais/resize-optimize-images/compare/v1.1.1...v1.1.2) 36 | 37 | ![👌 IMPROVE:](https://img.shields.io/badge/-IMPROVEMENT-gray.svg?colorB=39AA54) 38 | 39 | > 👌 RM Scarf [`9aab945`](https://github.com/ahmadawais/resize-optimize-images/commit/9aab945494c68a9e6b5d2dabbb57d7a494fc104b)
40 | 41 |
42 | 43 | [![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) 44 | 45 |
46 | 47 | ### RELEASE: [v1.1.1](https://github.com/ahmadawais/resize-optimize-images/compare/1.1.0...v1.1.1) 48 | 49 | ![📦 NEW:](https://img.shields.io/badge/-NEW-gray.svg?colorB=3778FF) 50 | 51 | > 📦 Analyze [`042d3f4`](https://github.com/ahmadawais/resize-optimize-images/commit/042d3f4ad3f712f83fa3c15404212a15e33e364e)
52 | 53 | ![🚀 RELEASE:](https://img.shields.io/badge/-RELEASE-gray.svg?colorB=E5A301) 54 | 55 | > 🚀 Patch [`292aef7`](https://github.com/ahmadawais/resize-optimize-images/commit/292aef72cee9c3b826bedece29dca733e4fa2e52)
56 | 57 |
58 | 59 | [![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) 60 | 61 |
62 | 63 | ### RELEASE: [1.1.0](https://github.com/ahmadawais/resize-optimize-images/compare/1.0.0...1.1.0) 64 | 65 | ![📖 DOC:](https://img.shields.io/badge/-DOCS-gray.svg?colorB=978CD4) 66 | 67 | > 📖 Changelog update [`fe7cc6a`](https://github.com/ahmadawais/resize-optimize-images/commit/fe7cc6aec153746867e286b9d370e29b90a07244)
68 | > 📖 Fix lingo [`ba99813`](https://github.com/ahmadawais/resize-optimize-images/commit/ba99813a2df5c40692ed8f3dcb5c01c31f3ed0b9)
69 | 70 |
71 | 72 | [![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) 73 | 74 |
75 | 76 | ### RELEASE: [1.0.0](https://github.com/ahmadawais/resize-optimize-images/compare/0.1.0...1.0.0) 77 | 78 | ![📦 NEW:](https://img.shields.io/badge/-NEW-gray.svg?colorB=3778FF) 79 | 80 | > 📦 Tests [`fec2948`](https://github.com/ahmadawais/resize-optimize-images/commit/fec294824ff51107169a957c949741dba334e531)
81 | > 📦 First version [`37a7d83`](https://github.com/ahmadawais/resize-optimize-images/commit/37a7d8376fc1702bf5cf82be206e3273e5793be5)
82 | > 📦 Options default [`249aaf3`](https://github.com/ahmadawais/resize-optimize-images/commit/249aaf3a9d56dc2c2c235223348cc82c78737988)
83 | > 📦 Jimp FTW [`7701693`](https://github.com/ahmadawais/resize-optimize-images/commit/7701693b5522fdfc831764c7c1de43488681fbfd)
84 | 85 | ![📖 DOC:](https://img.shields.io/badge/-DOCS-gray.svg?colorB=978CD4) 86 | 87 | > 📖 Documentation [`3b267a3`](https://github.com/ahmadawais/resize-optimize-images/commit/3b267a32862d775c23b6649d4fb86718d4a1659c)
88 | > 📖 Changelog update [`0f365bc`](https://github.com/ahmadawais/resize-optimize-images/commit/0f365bccaac183aaafc4f7370791a3570c7e6e71)
89 | > 📖 Function [`3bfa58a`](https://github.com/ahmadawais/resize-optimize-images/commit/3bfa58a1e0404b4d444738953b17ea14ddc9de82)
90 | 91 |
92 | 93 | [![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) 94 | 95 |
96 | 97 | ### RELEASE: 0.1.0 98 | 99 | ![📦 NEW:](https://img.shields.io/badge/-NEW-gray.svg?colorB=3778FF) 100 | 101 | > 📦 First commit [`da55299`](https://github.com/ahmadawais/resize-optimize-images/commit/da552994418f1f983e25d02d5caed7b7db1348a7)
102 | 103 | ![📖 DOC:](https://img.shields.io/badge/-DOCS-gray.svg?colorB=978CD4) 104 | 105 | > 📖 Changelog update [`87e4286`](https://github.com/ahmadawais/resize-optimize-images/commit/87e4286459255925743431555a3a718b3bcf93e8)
106 | 107 |
108 | 109 |
110 | 111 | [![📃](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/license.png)](/) 112 | 113 | ## License & Conduct 114 | 115 | - MIT © [Ahmad Awais](https://twitter.com/MrAhmadAwais/) 116 | - [Code of Conduct](code-of-conduct.md) 117 | 118 |
119 | 120 | [![🙌](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/connect.png)](/) 121 | 122 | ## Connect 123 | 124 |
125 |

GitHub @AhmadAwais (follow) TO STAY UP TO DATE ON FREE & OPEN SOURCE SOFTWARE

126 |

Twitter @MrAhmadAwais (follow) TO GET ONE DEV MINUTE DAILY HOT TIPS & TROLLS

127 |

YouTube AhmadAwais (subscribe) TO TECH TALKS & ONE DEV MINUTE VIDEOS

128 |

Blog: AhmadAwais.com (read) MOSTLY LONG FORM TECHNICAL ARTICLES

129 |

LinkedIn @MrAhmadAwais (connect) WITH THE LINKEDIN PROFILE Y'ALL

130 |
131 | 132 |
133 | 134 | [![👌](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/sponsor.png)](/) 135 | 136 | ## Sponsor 137 | 138 | Me ([Ahmad Awais](https://twitter.com/mrahmadawais/)) and my incredible wife ([Maedah Batool](https://twitter.com/MaedahBatool/)) are two engineers who fell in love with open source and then with each other. You can read more [about me here](https://ahmadawais.com/about). If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate. 139 | 140 | - 🌟 **$9.99/month (recommended)** ❯ [Two cups of Caffè latte (coffee) every month →](https://pay.paddle.com/checkout/540217) 141 | - 🚀 **$99.99 (one-time sponsor)** ❯ [Support an hour of open-source code →](https://pay.paddle.com/checkout/515568) 142 | - 🔰 **$49.99 (one-time sponsor)** ❯ [Support an hour of maintenance →](https://pay.paddle.com/checkout/527253) 143 | - ☕️ **$9.99 (one-time sponsor)** ❯ [Lunch/coffee →](https://pay.paddle.com/checkout/527254) 144 | 145 |
146 | 147 | [![Node CLI](https://img.shields.io/badge/-NodeCLI.com%20%E2%86%92-gray.svg?colorB=3D873A)](https://nodecli.com/?utm_source=FOSS) 148 | 149 | Or you can back me by checking out my super fun video course. After building hundreds of developer automation tools used by millions of developers, I am sharing exactly how you can do it yourself with minimum effective effort. Learn to build Node.js & JavaScript based CLI (Command Line Interface) apps. Automate the grunt work, do more in less time, impress your manager, and help the community. 150 | → I'm sharing it all in this online video course. Node CLI Automation 151 | without wasting a 1,000 hours

152 | 153 |
Node CLI
154 | 155 |
156 | 157 | > [**Support my work**][sponsor]: If you or your company use any of my projects or like what I’m doing then consider [backing me][sponsor]. I'm in this for the long run. An open-source developer advocate. 158 | 159 | [![Sponsor Awais](https://img.shields.io/badge/-Sponsor%20Awais%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://github.com/AhmadAwais/sponsor/?utm_source=FOSS) [![Node.js CLI Automation](https://img.shields.io/badge/-NodeCLI.com%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://NodeCLI.com/?utm_source=FOSS) 160 | [![VSCode](https://img.shields.io/badge/-VSCode.pro%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS) 161 | [![Follow @MrAhmadAwais on Twitter](https://img.shields.io/twitter/follow/mrahmadawais.svg?style=social&label=Follow%20@MrAhmadAwais)](https://twitter.com/mrahmadawais/) 162 | 163 | [![Sponsor](https://raw.githubusercontent.com/ahmadawais/stuff/master/sponsor/sponsor.jpg)][sponsor] 164 | 165 | [sponsor]: https://github.com/AhmadAwais/sponsor 166 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at me@AhmadAwais.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [https://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: https://contributor-covenant.org 74 | [version]: https://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /images/JAMstack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadawais/resize-optimize-images/a2ebf63096568830b9f9688163200e26af863998/images/JAMstack.jpg -------------------------------------------------------------------------------- /images/VSCode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadawais/resize-optimize-images/a2ebf63096568830b9f9688163200e26af863998/images/VSCode.jpg -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* RESIZE OPTIMIZE IMAGES */ 2 | const Jimp = require('jimp'); 3 | 4 | /** 5 | * Resize + optimize images. 6 | * 7 | * @param Object options Customizable Options. 8 | * @param Array images An array of images paths. 9 | * @param Number width A number value of width e.g. 1920. 10 | * @param Number height Optional number value of height e.g. 1080. 11 | * @param Number quality Optional number value of quality of the image e.g. 90. 12 | */ 13 | module.exports = async (options = {}) => { 14 | const defaultOptions = { 15 | images: [], 16 | width: 1920, 17 | height: Jimp.AUTO, 18 | quality: 90 19 | }; 20 | 21 | const opt = { ...defaultOptions, ...options }; 22 | await Promise.all( 23 | opt.images.map(async imgPath => { 24 | const image = await Jimp.read(imgPath); 25 | await image.resize(opt.width, opt.height); 26 | await image.quality(opt.quality); 27 | await image.writeAsync(imgPath); 28 | }) 29 | ); 30 | }; 31 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019-present Ahmad Awais. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resize-optimize-images", 3 | "version": "1.1.2", 4 | "description": "🗃 Resize and optimize bmp, gif, jpeg, png, & tiff images in Node.js.", 5 | "license": "MIT", 6 | "repository": "ahmadawais/resize-optimize-images", 7 | "author": { 8 | "name": "Ahmad Awais", 9 | "email": "me@AhmadAwais.com", 10 | "url": "https://twitter.com/MrAhmadAwais" 11 | }, 12 | "main": "index.js", 13 | "files": [ 14 | "index.js" 15 | ], 16 | "keywords": [ 17 | "resize-optimize-images", 18 | "Ahmad Awais", 19 | "ahmadawais" 20 | ], 21 | "scripts": { 22 | "test": "ava" 23 | }, 24 | "dependencies": { 25 | "jimp": "^0.6.4" 26 | }, 27 | "devDependencies": { 28 | "ava": "^2.2.0", 29 | "clear-any-console": "^1.16.0", 30 | "image-size": "^0.7.4" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # resize-optimize-images 2 | 3 | [![DOWNLOADS](https://img.shields.io/npm/dt/resize-optimize-images?label=DOWNLOADS%20%20❯&colorA=6A788D&colorB=6A788D&style=flat)](https://www.npmjs.com/package/resize-optimize-images) [![Learn VSCode](https://img.shields.io/badge/-VSCODE.pro%20%E2%86%92-gray.svg?colorB=6A788D&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS) 4 | [![Follow @MrAhmadAwais on Twitter](https://img.shields.io/badge/FOLLOW%20@MRAHMADAWAIS%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://twitter.com/mrahmadawais/) 5 | 6 | > 🗃 Resize and optimize bmp, gif, jpeg, png, & tiff images in Node.js. 7 | 8 |
9 | 10 | [![📟](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/install.png)](./../../) 11 | 12 | ## Install 13 | 14 | ```sh 15 | npm install resize-optimize-images 16 | ``` 17 | 18 |
19 | 20 | [![⚙️](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/usage.png)](./../../) 21 | 22 | ## Usage 23 | 24 | ```js 25 | const resizeOptimizeImages = require('resize-optimize-images'); 26 | 27 | (async () => { 28 | // Set the options. 29 | const options = { 30 | images: ['path/to/image.jpg', 'path/to/image.png'], 31 | width: 1920, 32 | quality: 90 33 | }; 34 | 35 | // Run the module. 36 | await resizeOptimizeImages(options); 37 | })(); 38 | ``` 39 | 40 |
41 | 42 | [![📃](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/options.png)](./../../) 43 | 44 | ## API 45 | 46 | ### resizeOptimizeImages(options) 47 | 48 | #### ❯ options 49 | 50 | Type: `object`
51 | 52 | You can specify the options below. 53 | 54 | ##### images 55 | 56 | Type: `Array`
57 | 58 | Array of paths to images that you want to resize and optimize. 59 | 60 | ##### width 61 | 62 | Type: `Number`
63 | Default: `1920` 64 | 65 | A number value of width e.g. 1920. 66 | 67 | ##### height 68 | 69 | Type: `Number`
70 | 71 | Optional number value of height e.g. 1080. If you don't pass a height then image is scaled accordingly with width to preserve the aspect ratio. 72 | 73 | ##### quality 74 | 75 | Type: `Number`
76 | Default: `90` 77 | 78 | Set image quality. `100` being the best quality. 79 | 80 |
81 | 82 | [![📝](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/log.png)](changelog.md) 83 | 84 | ## Changelog 85 | 86 | [❯ Read the changelog here →](changelog.md) 87 | 88 |
89 | 90 | **KEY**: `📦 NEW`, `👌 IMPROVE`, `🐛 FIX`, `📖 DOC`, `🚀 RELEASE`, and `✅ TEST` 91 | 92 | > _I use [Emoji-log](https://github.com/ahmadawais/Emoji-Log), you should try it and simplify your git commits._ 93 | 94 | 95 | 96 |
97 | 98 | [![📃](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/license.png)](./../../) 99 | 100 | ## License & Conduct 101 | 102 | - MIT © [Ahmad Awais](https://twitter.com/MrAhmadAwais/) 103 | - [Code of Conduct](code-of-conduct.md) 104 | 105 |
106 | 107 | [![🙌](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/connect.png)](./../../) 108 | 109 | ## Connect 110 | 111 |
112 |

GitHub @AhmadAwais (follow) To stay up to date on free & open-source software

113 |

Twitter @MrAhmadAwais (follow) To get #OneDevMinute daily hot tips & trolls

114 |

YouTube AhmadAwais (subscribe) To tech talks & #OneDevMinute videos

115 |

Blog: AhmadAwais.com (read) In-depth & long form technical articles

116 |

LinkedIn @MrAhmadAwais (connect) On the LinkedIn profile y'all

117 |
118 | 119 |
120 | 121 | [![👌](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/sponsor.png)](./../../) 122 | 123 | ## Sponsor 124 | 125 | Me ([Ahmad Awais](https://twitter.com/mrahmadawais/)) and my incredible wife ([Maedah Batool](https://twitter.com/MaedahBatool/)) are two engineers who fell in love with open source and then with each other. You can read more [about me here](https://ahmadawais.com/about). If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate. 126 | 127 | - 🌟 **$9.99/month (recommended)** ❯ [Two cups of Caffè latte (coffee) every month →](https://pay.paddle.com/checkout/540217) 128 | - 🚀 **$99.99 (one-time sponsor)** ❯ [Support an hour of open-source code →](https://pay.paddle.com/checkout/515568) 129 | - 🔰 **$49.99 (one-time sponsor)** ❯ [Support an hour of maintenance →](https://pay.paddle.com/checkout/527253) 130 | - ☕️ **$9.99 (one-time sponsor)** ❯ [Lunch/coffee →](https://pay.paddle.com/checkout/527254) 131 | 132 |
133 | 134 | Or you can back me by checking out my super fun video course. As developers, we spend over 200 Hrs/month with our code editors — it's only fair to learn your next editor deeply. This course will save you 15-20 hours every month. Become a VSCode Power User

135 | 136 |
VSCODE
137 | 138 |
139 | 140 | [![VSCode](https://img.shields.io/badge/-VSCode.pro%20%E2%86%92-gray.svg?colorB=4D2AFF&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS) 141 | [![Ahmad on Twitter](https://img.shields.io/twitter/follow/mrahmadawais.svg?style=social&label=Follow%20@MrAhmadAwais)](https://twitter.com/mrahmadawais/) 142 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const clearConsole = require('clear-any-console'); 2 | const resizeOptimizeImages = require('./index.js'); 3 | const sizeOf = require('image-size'); 4 | const test = require('ava'); 5 | 6 | (async () => { 7 | clearConsole(); 8 | const images = [`${__dirname}/images/VSCode.jpg`, `${__dirname}/images/JAMstack.jpg`]; 9 | 10 | // Usage. 11 | await resizeOptimizeImages({ 12 | images, 13 | width: 1920, 14 | quality: 90 15 | }); 16 | 17 | // Tests. 18 | images.map(async (image, i) => { 19 | let dimensions = await sizeOf(image); 20 | 21 | test(`${i}: should be 1920`, t => { 22 | t.is(dimensions.width, 1920); 23 | }); 24 | }); 25 | })(); 26 | --------------------------------------------------------------------------------