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

Feature: Support importation of transparent images (alpha channel) #604

Closed
remusonline opened this issue Jan 13, 2020 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@remusonline
Copy link
Collaborator

Cboard currently does not support (at least using firefox or chrome) the importation of transparent images (alpha channel or transparent color). A workaround is to provide images with the same background color as the button color, but it is not practical. Transparent image formats (e.g. gif, png, svg, etc.) should be supported, especially considering that images from mulberry can be displayed with transparency.

Currently, importing a transparent image will result in a black background instead of the expected transparency.

Please contact me or comment on this issue if you need further info. Thanks!

@remusonline
Copy link
Collaborator Author

The following modification should do the trick, but I don't know if there will be side effects to this. The default MIME type for browser-image-resizer is image/jpeg, which does not support transparency. By defining a MIME type of image/png, transparency is now supported. I tried it using png, jpeg and SVG without side effects. Here is the modification to perform in InputImage.component.js (add mimeType: 'image/png' to the configuration):

  async resizeImage(
    file,
    config = {
      quality: 7,
      maxWidth: 200,
      maxHeight: 200,
      autoRotate: true,
      debug: false,
      mimeType: 'image/png'
    }
  )

Can someone try this on their system using other platforms/browsers? I tried it with chrome and firefox on windows, and chrome on Android. Thanks for your feedback!

@martinbedouret
Copy link
Collaborator

@remusonline great suggestion !! It worked perfectly, I have added you as a project collaborator and created a PR: #606

@martinbedouret martinbedouret added this to the 1.1.3 milestone Jan 20, 2020
@martinbedouret martinbedouret self-assigned this Jan 20, 2020
@martinbedouret
Copy link
Collaborator

this has been added and merged

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

No branches or pull requests

2 participants