Skip to content
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

Deprecation notice: move background function to relevant operations, affects embed/extend/flatten #1392

Closed
lovell opened this issue Sep 27, 2018 · 4 comments

Comments

@lovell
Copy link
Owner

lovell commented Sep 27, 2018

This is advance warning that the background method will be deprecated in v0.21.0 and instead become separate options of the operations it affects.

embed

The following:

sharp(input)
  .background({
    r: 0,
    g: 255,
    b: 0,
    alpha: 0.1
  })
  .resize(200, 300)
  .embed()
  ...

when combined with #1135 will become:

sharp(input)
  .resize({
    width: 200,
    height: 300,
    fit: 'contain',
    background: {
      r: 0,
      g: 255,
      b: 0,
      alpha: 0.1
    }
  })
  ...

extend

The following:

sharp(input)
  .background({
    r: 255,
    g: 0,
    b: 0,
    alpha: 0.5
  })
  .extend({
    top: 10,
    bottom: 20,
    left: 10,
    right: 10
  })
  ...

will become:

sharp(input)
  .extend({
    top: 10,
    bottom: 20,
    left: 10,
    right: 10,
    background: {
      r: 255,
      g: 0,
      b: 0,
      alpha: 0.5
    }
  })
  ...

flatten

The following:

sharp(input)
  .background('red')
  .flatten()
  ...

will become:

sharp(input)
  .flatten({
    background: 'red'
  })
  ...
@lovell
Copy link
Owner Author

lovell commented Oct 1, 2018

Commit a648446 deprecates background from v0.21.0 (and will be removed in v0.22.0).

@lovell
Copy link
Owner Author

lovell commented Oct 4, 2018

v0.21.0 now available with this change.

@lovell lovell closed this as completed Oct 4, 2018
@rn4391
Copy link

rn4391 commented Oct 8, 2018

How do we just add a background to a PNG image with transparency - no other transform, just replace the transparency with a color?

@lovell
Copy link
Owner Author

lovell commented Oct 8, 2018

@rn4391 Please can you create a new issue with your question and an example of what you've tried that didn't work e.g. flatten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants