Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
938 bytes
|
Line | |
---|
1 | #!/usr/bin/env node
|
---|
2 | 'use strict';
|
---|
3 |
|
---|
4 | var fs = require('fs');
|
---|
5 | var path = require('path');
|
---|
6 |
|
---|
7 | var imageSize = require('..');
|
---|
8 |
|
---|
9 | var files = process.argv.slice(2);
|
---|
10 |
|
---|
11 | if (!files.length) {
|
---|
12 | console.error('Usage: image-size image1 [image2] [image3] ...');
|
---|
13 | process.exit(-1);
|
---|
14 | }
|
---|
15 |
|
---|
16 | var red = ['\x1B[31m', '\x1B[39m'];
|
---|
17 | // var bold = ['\x1B[1m', '\x1B[22m'];
|
---|
18 | var grey = ['\x1B[90m', '\x1B[39m'];
|
---|
19 | var green = ['\x1B[32m', '\x1B[39m'];
|
---|
20 |
|
---|
21 | files.forEach(function (image) {
|
---|
22 | try {
|
---|
23 | if (fs.existsSync(path.resolve(image))) {
|
---|
24 | var size = imageSize(image);
|
---|
25 | var label = green[0] + size.width + green[1] +
|
---|
26 | grey[0] + 'x' + grey[1] +
|
---|
27 | green[0] + size.height + green[1];
|
---|
28 | console.info(label, '-', grey[0] + image + grey[1]);
|
---|
29 | } else {
|
---|
30 | console.error('file doesn\'t exist - ', image);
|
---|
31 | }
|
---|
32 | } catch (e) {
|
---|
33 | // console.error(e.stack);
|
---|
34 | console.error(red[0] + e.message + red[1], '-', image);
|
---|
35 | }
|
---|
36 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.