Skip to content

Feature request: Embed Transparent #86

Closed

Description

@ssured

My need is resizing landscape and portrait photos to square thumbs (png). Instead of cropping to cover, I want the images to fit inside the square. EmbedWhite and EmbedBlack work perfect here, but I'd like to EmbedTransparent, as my images are on a greyish background.

Thanks for this awesome performing lib!

Activity

  1. lovell commented on Sep 10, 2014

    @lovell
    Owner

    Good idea, should be possible. Some thoughts for when I get round to implementing this:

    • need to add an alpha channel/band if there isn't already one present
    • applicable for PNG and WebP output
    • might want to modify the embed* API method(s) slightly to accommodate this

    Thanks for the suggestion.

  2. lovell commented on Sep 15, 2014

    @lovell
    Owner

    The inverse of this feature would be to specify the background colour when converting from transparent PNG/WebP images to JPEG - see jcupitt/libvips@b21c47b

  3. ssured commented on Sep 15, 2014

    @ssured
    Author

    This approach makes sense to me. Assuming an image to have an alpha channel is reasonable IMO. Default colour for flattening a transparent image to jpg is white I guess.

    On 15 Sep 2014, at 16:07, Lovell Fuller [email protected] wrote:

    The inverse of this feature would be to specify the background colour when converting from transparent PNG/WebP images to JPEG - see jcupitt/libvips@b21c47b

    —
    Reply to this email directly or view it on GitHub.

  4. added this to the v0.7.0 milestone on Oct 2, 2014
  5. added a commit that references this issue on Oct 2, 2014
  6. lovell commented on Oct 2, 2014

    @lovell
    Owner

    Hi @ssured, are you able to verify the new background and embed methods on the alpha branch meet your needs?

    npm install lovell/sharp#alpha
    
  7. ssured commented on Oct 7, 2014

    @ssured
    Author

    Hey @lovell, I just tested and it works like a charm. Awesome stuff. As I am on holiday I am not able to test any further, but a drop in replacement using .background({r: 0, g: 0, b: 0, a: 0}).embed() did the trick. Thanks!

  8. lovell commented on Oct 7, 2014

    @lovell
    Owner

    Great news, thank you for confirming.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions