ericnograles / browser-image-resizer

A tiny browser-based library to downscale and/or resize images using canvas
MIT License
98 stars 42 forks source link

Transparency replaced with white #66

Closed johnpturner8 closed 2 years ago

johnpturner8 commented 2 years ago

When processing a PNG with transparency, the transparency is removed and replaced with a white background, even when the mimeType is set to PNG in the config.

This seems to be caused by the fix for https://github.com/ericnograles/browser-image-resizer/issues/42, PNGs retain their transparency in the previous version.

ericnograles commented 2 years ago

@johnpturner8 ah good catch, let me see about plugging this bug.

ericnograles commented 2 years ago

Got a fix in place, will push out a new version to NPM shortly.

Transparent PNG => mimeType: 'image/png'

image

Transparent PNG => mimeType: 'image/jpeg'

image

JPEG => mimeType: 'image/jpeg'

image
jz222 commented 2 years ago

Hi,

I'm using 2.4.1 and still have this issue. It adds a white background to PNG's with transparent background @ericnograles.

ericnograles commented 2 years ago

@jz222 huh strange, pretty sure I tested it. Did you set the mimeType to image/png? By default, if nothing is specified, the library assumes image/jpeg which will give your PNG a white background by design.