6.1.0 • Published 10 years ago

locator-image-utility v6.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

locator-image-utility

Utility module for providing useful operations regarding handling images.

Install

include it in your project

npm install locator-image-utility

Usage

Regex

// access various regexes
var regex = require('locator-image-utility').regex

regex.imageContentType.match('image/png') // or jpg/jpeg

regex.imageExtension.match('png') //or jpg/jpeg

regex.routePrefix.match('/api/v1/trips/') // everything within four slashes

Validation

// get the validation
var validation = require('locator-image-utility').validation

    // route with image payload
    ...
    payload: validation.basicImageSchema,
    ...

Image Processing

// create a image processing unit
var imageUtil = require('locator-image-utility').image

    // route with image payload
    ...
    var imageProcessor = imageUtil.processor(request); // request must be a request object from hapi
    
    // will return a useful object containing information about the file
    file = imageProcessor.createFileInformation(nameOfFile);
    
    // will return an object used for saving the picture to couchdb
    imageProcessor.getAttachmentData(file.filename); 
    
    // will crop the stream according to the values in the **request**. The parameters are used for resizing
    stream = imageProcessor.createCroppedStream(100, 100); 
    
    stream.pipe(someStreamFromDatabase);
    ...

Sizes

The following sizes are used to request a picture with the query `?size=

 - max:
    size: { x: 1400, y: 819}
    name: 'max'
 - mid :
    size: {x: 700, y: 410}
    name: 'mid'

 - small:
    size: {x: 400,y: 234}
    name: 'small'

 - user:
    size: {x: 150,y: 150}
    name: 'user'

 - userThumb:
    size: {x: 50,y: 50},
    name: 'userThumb'
6.1.0

10 years ago

6.0.0

10 years ago

5.1.0

10 years ago

5.0.0

10 years ago

4.1.0

10 years ago

4.0.0

10 years ago

3.0.0

10 years ago

2.1.0

10 years ago

2.0.5

10 years ago

2.0.4

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago