steveathon / bootstrap-wysiwyg

Tiny bootstrap-compatible WYSIWYG rich text editor
MIT License
661 stars 1.71k forks source link

Image size restriction increases file size #138

Open SridharRamasami opened 6 years ago

SridharRamasami commented 6 years ago

Hi, Im using the image size restrictions as below var userOptions = { enableImageSizeRestrictions: true, imageMaxWidth: 500, imageMaxHeight: 500 }

When the input is a jpg of 700x525px with a file size of 265kb the output is a png of 599x375px and a file size of 467.8kb Node version 9.10.1 Ubuntu16

This error has occured in different version of node and different versions of Ubuntu.

If you need any further information, please let me know.

spreadred commented 6 years ago

@SridharRamasami I assume this is occurring using my fork, as image resize is not implemented in original repo?

SridharRamasami commented 6 years ago

Hi Kaptain, Yes. Im using your fork. Looks like base 64 increases the size when converted from binary. Also browsers do not compress the image efficiently.
Any work arounds you can think of?

SridharRamasami commented 6 years ago

Worked around it by asking it to return a jpg instead of a png. Works well now. return fc.toDataURL("image/jpeg", 0.8);

Not sure whether to call it a bug or not. Maintainers, feel free to close this if you think its not.

spreadred commented 6 years ago

@SridharRamasami Thanks for reporting this issue and providing a workaround. At this point I'd say it is certainly unintended behavior, but perhaps not a bug. I never bothered to check on the resulting file size of the images after resizing. I will look into this and perform some further tests with images of different resolutions before determining how I'd like to resolve the issue.