Avatar file size bug?
-
So I tried to change my avatar this morning and ran into the "Maximum file size is 512kb" error.
I didn't think much of it, and started to look into a file converter to try and reduce the file size...except the file I've uploaded is only 364kb.
Is NodeBB doing some sort of stupid wizardry that's making that file get bigger when uploaded and trying to set it as an avatar?
-
@e4tmyl33t said in Avatar file size bug?:
the file I've uploaded is only 364kb
No, it's only 360 kB.
"Size on disk" includes the dead space at the end of it, which is there because the file had to fit into an integer number of 4 kB disk blocks. It's not really part of the file, though, so nothing that reads the file should see it.
@e4tmyl33t said in Avatar file size bug?:
Is NodeBB doing some sort of stupid wizardry that's making that file get bigger when uploaded and trying to set it as an avatar?
Very likely. My best guess is that it's resizing the image. Try resizing it to 128x128 pixels, verify that it's still under 512 kB, and see if it works then.
-
@anotherusername Well, given that the original is 1024x1064, and generating a 128x128 resized PNG brought the file size down to 25kb...I have no idea what it's doing with its resizing that made the file size bigger.
-
-
@anotherusername Indeed. Apparently even NodeBB's funny resizing maths aren't bad enough to take a 25kb file and balloon it over 512kb...
-
@e4tmyl33t I'm reasonably sure that since it saw that the image was already 128x128, it actually didn't bother with resizing it.
-
@e4tmyl33t said in Avatar file size bug?:
@anotherusername Well, given that the original is 1024x1064, and generating a 128x128 resized PNG brought the file size down to 25kb...I have no idea what it's doing with its resizing that made the file size bigger.
Perhaps (despite the error message) it cares more about the memory used as a bitmap than the size of the file in its original file format? 1024*1064*4 (or 3) is well over 512 kB.
-
I avoided this entire thing by uploading a 16x16 avatar.
-
@pie_flavor so NodeBB used nearest-neighbor to resize it to 128x128 when nearly everything known to man has an unconfigurable default that isn't nearest-neighbor? Good on you, NodeBB devs, for using a sane default for image resizing.