source: trip-planner-front/node_modules/image-size/Readme.md@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1# image-size
2
3[![NPM Version](https://img.shields.io/npm/v/image-size.svg)](https://www.npmjs.com/package/image-size)
4[![Build Status](https://travis-ci.org/image-size/image-size.svg?branch=master)](https://travis-ci.org/image-size/image-size)
5[![NPM Downloads](https://img.shields.io/npm/dm/image-size.svg)](http://npm-stat.com/charts.html?package=image-size&author=&from=&to=)
6[![Coverage Status](https://img.shields.io/coveralls/image-size/image-size/master.svg)](https://coveralls.io/github/image-size/image-size?branch=master)
7[![devDependency Status](https://david-dm.org/image-size/image-size/dev-status.svg)](https://david-dm.org/image-size/image-size#info=devDependencies)
8
9A [Node](https://nodejs.org/en/) module to get dimensions of any image file
10
11## Supported formats
12
13* BMP
14* GIF
15* JPEG
16* PNG
17* PSD
18* TIFF
19* WebP
20* SVG
21* DDS
22
23### Upcoming
24
25* SWF
26
27## Programmatic Usage
28
29```
30npm install image-size --save
31```
32
33### Synchronous
34
35```javascript
36var sizeOf = require('image-size');
37var dimensions = sizeOf('images/funny-cats.png');
38console.log(dimensions.width, dimensions.height);
39```
40
41### Asynchronous
42
43```javascript
44var sizeOf = require('image-size');
45sizeOf('images/funny-cats.png', function (err, dimensions) {
46 console.log(dimensions.width, dimensions.height);
47});
48```
49NOTE: The asynchronous version doesn't work if the input is a Buffer. Use synchronous version instead.
50
51### Using a URL
52
53```javascript
54var url = require('url');
55var http = require('http');
56
57var sizeOf = require('image-size');
58
59var imgUrl = 'http://my-amazing-website.com/image.jpeg';
60var options = url.parse(imgUrl);
61
62http.get(options, function (response) {
63 var chunks = [];
64 response.on('data', function (chunk) {
65 chunks.push(chunk);
66 }).on('end', function() {
67 var buffer = Buffer.concat(chunks);
68 console.log(sizeOf(buffer));
69 });
70});
71```
72
73You can optionally check the buffer lengths & stop downloading the image after a few kilobytes.
74**You don't need to download the entire image**
75
76## Command-Line Usage (CLI)
77
78```
79npm install image-size --global
80image-size image1 [image2] [image3] ...
81```
82
83## Credits
84
85not a direct port, but an attempt to have something like
86[dabble's imagesize](https://github.com/dabble/imagesize/blob/master/lib/image_size.rb) as a node module.
87
88## [Contributors](Contributors.md)
Note: See TracBrowser for help on using the repository browser.