Skip to content

Commit

Permalink
Allow for canvas parsing
Browse files Browse the repository at this point in the history
This is the same as fitting the image, but additionally it fills the bordesr until the exact desired height and width
  • Loading branch information
rogierslag committed May 3, 2016
1 parent 279d580 commit 5ac598f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 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

0 comments on commit 5ac598f

Please sign in to comment.