Skip to content

Sharp fit #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const defaultConfig = {
withoutChromaSubsampling: false,
compressionLevel: 6,
format: null,
trim: false
trim: false,
fit: 'cover'
Copy link
Collaborator

@StarpTech StarpTech Jun 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default option is centre https://sharp.pixelplumbing.com/api-resize#resize that change would be breaking.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're mistaking. According to the documentation the "fit" parameter default value is "cover". See here :
https://sharp.pixelplumbing.com/api-resize#resize
Centre is the "position" param default value.

}

function prepareConfig (config, globalConfig) {
Expand Down
3 changes: 2 additions & 1 deletion lib/sharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module.exports = async function sharpVinyl (file, config, options) {
image.resize(width, height, {
background: config.background,
kernel: config.kernel,
withoutEnlargement: config.withoutEnlargement
withoutEnlargement: config.withoutEnlargement,
fit: config.fit
})

if (config.extractAfterResize) {
Expand Down
1 change: 1 addition & 0 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('gulp-responsive', function () {
assert.strictEqual(config[0].withoutChromaSubsampling, false)
assert.strictEqual(config[0].compressionLevel, 6)
assert.strictEqual(config[0].format, null)
assert.strictEqual(config[0].fit, 'cover')
})

it('should not override specified values', function () {
Expand Down