Resizing Images
Doka has multiple different resize options. It can automatically resize the image to a set target bounding box. It can also offer the user control over the image output size.
Automatically resizing an image
We can use the outputWidth
and outputHeight
properties to set an output size. To enable resizing of the output image only of the two properties is required.
Doka will resize the image to cover the created output size.
An example. If both outputWidth
and outputHeight
have been set to 200 and the crop made is 400 × 300, the height of the output image will be 200 and the width will be scaled down accordingly to 266.
Doka will always make sure the output image covers the defined output size. You can adjust this by setting the outputFit
property.
Changing the output size algorithm
The outputFit
property will determine how Doka fits the image to the defined output size.
- The
'force'
value will force the image to the output size, no matter if its aspect ratio matches the crop aspect ratio, this might result in skewed images. - The
'cover'
value will scale up the image so it covers the output size. This will result in either the width or the height overflowing but the aspect ratio will be maintained. - The
'contain'
value will scale down the image so it fits inside the output size. Resulting in an image that is smaller than one of the defined axis but aspect ratio is maintained.
Manually resizing an image
The 'resize'
util allows the user to manually enter output size information. Enable this functionality by adding it to the utils
list.
Doka.create({
utils: [
// other utils here,
'resize'
]
})