Skip to content

Commit

Permalink
Merge pull request inventid#66 from inventid/canvas-fitting
Browse files Browse the repository at this point in the history
Allow for canvas parsing
  • Loading branch information
rogierslag committed May 3, 2016
2 parents 279d580 + 7914eab commit 882135a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions UrlParsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* [5] The scaling parameter (for retina)
* [6] The file type
* [7] The query string, dont use this, use [8] instead
* [8] The format (either clip or crop)
* [8] The format (either clip or crop or canvas)
* @param url The url to parse
* @returns {Array|{index: number, input: string}|*|{ID, CLASS, NAME, ATTR, TAG, CHILD, POS, PSEUDO}}
*/
Expand Down Expand Up @@ -62,7 +62,7 @@ const UrlParsing = {
fit: 'clip'
};

if (matches[8] && ['clip', 'crop'].indexOf(matches[8].toLowerCase()) > -1) {
if (matches[8] && ['clip', 'crop', 'canvas'].indexOf(matches[8].toLowerCase()) > -1) {
res.fit = matches[8].toLowerCase();
}

Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ function correctlyResize(file, params, callback) {
} else {
workImageClient = workImageClient.resize(params.resolutionX, params.resolutionY);
}
if (params.fit === 'canvas') {
workImageClient = workImageClient.gravity('Center').extent(params.resolutionX, params.resolutionY);
}
//Interlacing for png isn't efficient (both in filesize as render performance), so we only do it for jpg
if (params.fileType === 'jpg') {
workImageClient = workImageClient.interlace('Line');
Expand Down
10 changes: 4 additions & 6 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ language: node_js
notifications:
email: false

install:
- npm install eslint -g

script:
- eslint .

build:
ci:
- npm install eslint -g
- eslint .

0 comments on commit 882135a

Please sign in to comment.