@@ -85,25 +85,25 @@ sharp('input.jpg').resize(300, 200).write('output.jpg', function(err) {
8585```
8686
8787``` javascript
88- sharp (' input.jpg' ).resize (null , 200 ).progressive ().toBuffer (function (err , buffer ) {
88+ sharp (' input.jpg' ).resize (null , 200 ).progressive ().toBuffer (function (err , outputBuffer ) {
8989 if (err) {
9090 throw err;
9191 }
92- // buffer contains progressive JPEG image data, 200 pixels high
92+ // outputBuffer contains progressive JPEG image data, 200 pixels high
9393});
9494```
9595
9696``` javascript
97- sharp (' input.png' ).resize (300 ).sharpen ().quality (90 ).webp (function (err , buffer ) {
97+ sharp (' input.png' ).resize (300 ).sharpen ().quality (90 ).webp (function (err , outputBuffer ) {
9898 if (err) {
9999 throw err;
100100 }
101- // buffer contains 300 pixels wide, sharpened, 90% quality WebP image data
101+ // outputBuffer contains 300 pixels wide, sharpened, 90% quality WebP image data
102102});
103103```
104104
105105``` javascript
106- sharp (buffer ).resize (200 , 300 ).embedWhite ().write (' output.tiff' , function (err ) {
106+ sharp (inputBuffer ).resize (200 , 300 ).embedWhite ().write (' output.tiff' , function (err ) {
107107 if (err) {
108108 throw err;
109109 }
@@ -113,15 +113,25 @@ sharp(buffer).resize(200, 300).embedWhite().write('output.tiff', function(err) {
113113```
114114
115115``` javascript
116- sharp (' input.gif' ).resize (200 , 300 ).embedBlack ().webp (function (err , buffer ) {
116+ sharp (' input.gif' ).resize (200 , 300 ).embedBlack ().webp (function (err , outputBuffer ) {
117117 if (err) {
118118 throw err;
119119 }
120- // buffer contains WebP image data of a 200 pixels wide and 300 pixels high image
120+ // outputBuffer contains WebP image data of a 200 pixels wide and 300 pixels high
121121 // containing a scaled version, embedded on a black canvas, of input.gif
122122});
123123```
124124
125+ ``` javascript
126+ sharp (inputBuffer).resize (200 , 200 ).max ().jpeg (function (err , outputBuffer ) {
127+ if (err) {
128+ throw err;
129+ }
130+ // outputBuffer contains JPEG image data no wider than 200 pixels and no higher
131+ // than 200 pixels regardless of the inputBuffer image dimensions
132+ });
133+ ```
134+
125135## API
126136
127137### sharp(input)
@@ -147,6 +157,8 @@ Crop the resized image to the exact size specified, the default behaviour.
147157
148158Preserving aspect ratio, resize the image to the maximum width or height specified.
149159
160+ Both ` width ` and ` height ` must be provided via ` resize ` otherwise the behaviour will default to ` crop ` .
161+
150162### embedWhite()
151163
152164Embed the resized image on a white background of the exact size specified.
0 commit comments