1 | # ImP
|
2 |
|
3 | ![npm (scoped)](https://img.shields.io/npm/v/@mischback/imp?style=flat)
|
4 | [![install size](https://packagephobia.com/badge?p=@mischback/imp)](https://packagephobia.com/result?p=@mischback/imp)
|
5 |
|
6 | ![GitHub package.json version (development)](https://img.shields.io/github/package-json/v/mischback/imp/development?style=flat)
|
7 | ![GitHub branch checks state](https://img.shields.io/github/workflow/status/mischback/imp/CI%20default%20branch?style=flat&logo=github)
|
8 | [![Coverage Status](https://coveralls.io/repos/github/Mischback/imp/badge.svg)](https://coveralls.io/github/Mischback/imp)
|
9 | [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat&logo=prettier)](https://github.com/prettier/prettier)
|
10 | ![GitHub License](https://img.shields.io/github/license/mischback/imp?style=flat)
|
11 |
|
12 | **ImP** is the abbreviation of _image processor_. Basically it is a wrapper
|
13 | around the wonderful [Sharp](https://github.com/lovell/sharp) module, providing
|
14 | an easy to use interface to make Sharp usable in a front-end development
|
15 | workflow.
|
16 |
|
17 | ## Installation
|
18 |
|
19 | Just install _ImP_ from **npm**:
|
20 |
|
21 | ```bash
|
22 | npm install --save-dev @mischback/imp
|
23 | ```
|
24 |
|
25 | Most likely you will want to install it as a development dependency for internal
|
26 | usage (see below for _Security Considerations_).
|
27 |
|
28 | ## Usage
|
29 |
|
30 | After installation, _ImP_ is available using the following command:
|
31 |
|
32 | ```bash
|
33 | npx imp
|
34 | ```
|
35 |
|
36 | Please note, that a configuration file is required, see below for configuration
|
37 | options and command line parameters.
|
38 |
|
39 | A more sophisticated usage example is provided in the
|
40 | [advanced usage guide](https://github.com/Mischback/imp/blob/development/docs/advanced-usage.md).
|
41 |
|
42 | ## Configuration
|
43 |
|
44 | _ImP_ is configured by its configuration file and command line parameters.
|
45 | Providing a configuration file (or the corresponding key in `package.json`) is
|
46 | mandatory, as the `TargetConfig` and `FormatConfig` can not be specified by
|
47 | command line.
|
48 |
|
49 | The in-depth description of the configuration file is provided in
|
50 | [the configuration guide](https://github.com/Mischback/imp/blob/development/docs/configuration.md).
|
51 |
|
52 | ### Configuration File
|
53 |
|
54 | _ImP_ uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) to
|
55 | retrieve and read the configuration file.
|
56 |
|
57 | The following locations are searched:
|
58 |
|
59 | - key "imp" in `package.json`
|
60 | - an extensionless "rc file", in YAML or JSON format: `.imprc`
|
61 | - an "rc file" with extension: `.imprc.json`, `.imprc.yaml`, `.imprc.yml`, `.imprc.js` or `.imprc.cjs`
|
62 | - a `.config.js` or `.config.cjs` CommonJS module
|
63 |
|
64 | The listed filenames/locations are checked in the current working directory and
|
65 | then the search is continued upwards (see [cosmiconfig's README](https://github.com/davidtheclark/cosmiconfig/README.md) for further details).
|
66 |
|
67 | ### Configuration by Command Line
|
68 |
|
69 | Additionally, _ImP_ accepts the following command line parameters:
|
70 |
|
71 | - `--debug`, `-d`: Activate the debug mode; in this mode, cosmiconfig's caching is cleared and additional log messages are emitted;
|
72 | - `--configFile`, `-c`: Specify another name/location for the configuration file to be used;
|
73 | - `--inputFile`, `-i`: Specify the name/location of the image to be processed. This option may be specified multiple times;
|
74 | - `--outputDir`, `-o`: Specify the directory to write the processed images to;
|
75 | - `--quiet`, `-q`: Suppress all output.
|
76 |
|
77 | Please note that providing `--inputFile` and `--outputDir` through
|
78 | command line parameters will overwrite the corresponding parameter in the
|
79 | configuration file.
|
80 |
|
81 | ## Security Considerations
|
82 |
|
83 | _ImP_ was developed without any special regard to security. It is assumed to be
|
84 | used in a safe environment, meaning that input and output are under strict of
|
85 | the user.
|
86 |
|
87 | You should not expose _ImP_ publicly, at least not without some wrapper that
|
88 | does perform sanitarization of any user input.
|
89 |
|
90 | ## What about this crazy install size?
|
91 |
|
92 | _ImP_ is a wrapper around Sharp, which is in fact a very capable interface to
|
93 | [libvips](https://github.com/libvips/libvips) itsself.
|
94 |
|
95 | The install size actually reflects the installation of _libvips_.
|
96 |
|
97 | ## Contributing
|
98 |
|
99 | Issues, pull requests and feature requests are welcome. Just use the project's
|
100 | [issue tracker](https://github.com/mischback/imp/issues).
|
101 |
|
102 | _ImP_ is implemented in TypeScript and compiled/transpiled to actual JavaScript
|
103 | on release.
|
104 |
|
105 | More details about the internal guidelines regarding code formatting, linting,
|
106 | testing and releasing are provided in `docs/`.
|
107 |
|
108 | ## License
|
109 |
|
110 | [MIT](https://choosealicense.com/licenses/MIT)
|