derhuerst / gulp-scale-images

Gulp plugin to resize each image into multiple smaller variants.
https://github.com/derhuerst/gulp-scale-images#gulp-scale-images
ISC License
13 stars 5 forks source link

Specifying both maxWidth and maxHeight does not respect aspect ratio #17

Closed kari closed 5 years ago

kari commented 5 years ago

According to Sharp documentation the default resizing strategy is "cover" and it will crop if both maxWidth and maxHeight are defined. To respect the aspect ratio, the resize.js should should use the fit parameter 'inside':

task.resize(cfg.maxWidth, cfg.maxHeight || null, {
    withoutEnlargement: !cfg.allowEnlargement,  
    fit: 'inside'
})

Also, the default naming in compute-file-name.js has double dots in before the extension because path.extname already includes the dot and the join adds another.

derhuerst commented 5 years ago

Thanks for reporting.

PR(s) welcome! Please add the fixes as separate commits.

I'm not sure if adding fit: 'inside' is a breaking change. 🤔

derhuerst commented 5 years ago

Fixed in #18 and #19. Published as gulp-scale-images@1.2.2.