UNPKG

4.47 kBMarkdownView Raw
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
13around the wonderful [Sharp](https://github.com/lovell/sharp) module, providing
14an easy to use interface to make Sharp usable in a front-end development
15workflow.
16
17## Installation
18
19Just install _ImP_ from **npm**:
20
21```bash
22npm install --save-dev @mischback/imp
23```
24
25Most likely you will want to install it as a development dependency for internal
26usage (see below for _Security Considerations_).
27
28## Usage
29
30After installation, _ImP_ is available using the following command:
31
32```bash
33npx imp
34```
35
36Please note, that a configuration file is required, see below for configuration
37options and command line parameters.
38
39A 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.
45Providing a configuration file (or the corresponding key in `package.json`) is
46mandatory, as the `TargetConfig` and `FormatConfig` can not be specified by
47command line.
48
49The 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
55retrieve and read the configuration file.
56
57The 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
64The listed filenames/locations are checked in the current working directory and
65then 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
69Additionally, _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
77Please note that providing `--inputFile` and `--outputDir` through
78command line parameters will overwrite the corresponding parameter in the
79configuration file.
80
81## Security Considerations
82
83_ImP_ was developed without any special regard to security. It is assumed to be
84used in a safe environment, meaning that input and output are under strict of
85the user.
86
87You should not expose _ImP_ publicly, at least not without some wrapper that
88does 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
95The install size actually reflects the installation of _libvips_.
96
97## Contributing
98
99Issues, 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
103on release.
104
105More details about the internal guidelines regarding code formatting, linting,
106testing and releasing are provided in `docs/`.
107
108## License
109
110[MIT](https://choosealicense.com/licenses/MIT)