Skip to content

Commit

Permalink
Merge pull request #167 from oddstr13/image-fill-resize
Browse files Browse the repository at this point in the history
Add fillWidth and fillHeight image parameters
  • Loading branch information
oddstr13 committed Apr 11, 2021
2 parents 4da6676 + 885eec2 commit 4de8f08
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2389,8 +2389,10 @@ class ApiClient {
* Options supports the following properties:
* width - download the image at a fixed width
* height - download the image at a fixed height
* maxWidth - download the image at a maxWidth
* maxHeight - download the image at a maxHeight
* maxWidth - download the image at a maxWidth (touch box on the inside)
* maxHeight - download the image at a maxHeight (touch box on the inside)
* fillWidth - scale the image down to fill a fillWidth wide box (touch box on the outside)
* fillHeight - scale the image down to fill a fillHeight high box (touch box on the outside)
* quality - A scale of 0-100. This should almost always be omitted as the default will suffice.
* For best results do not specify both width and height together, as aspect ratio might be altered.
*/
Expand Down Expand Up @@ -2425,8 +2427,10 @@ class ApiClient {
* index - When downloading a backdrop, use this to specify which one (omitting is equivalent to zero)
* width - download the image at a fixed width
* height - download the image at a fixed height
* maxWidth - download the image at a maxWidth
* maxHeight - download the image at a maxHeight
* maxWidth - download the image at a maxWidth (touch box on the inside)
* maxHeight - download the image at a maxHeight (touch box on the inside)
* fillWidth - scale the image down to fill a fillWidth wide box (touch box on the outside)
* fillHeight - scale the image down to fill a fillHeight high box (touch box on the outside)
* quality - A scale of 0-100. This should almost always be omitted as the default will suffice.
* For best results do not specify both width and height together, as aspect ratio might be altered.
*/
Expand Down Expand Up @@ -4169,6 +4173,12 @@ function normalizeImageOptions(instance, options) {
if (options.maxHeight) {
options.maxHeight = Math.round(options.maxHeight * ratio);
}
if (options.fillWidth) {
options.fillWidth = Math.round(options.fillWidth * ratio);
}
if (options.fillHeight) {
options.fillHeight = Math.round(options.fillHeight * ratio);
}
}

options.quality = options.quality || instance.getDefaultImageQuality(options.type);
Expand Down

0 comments on commit 4de8f08

Please sign in to comment.