-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix and improve autoscaling behavior #395
base: develop
Are you sure you want to change the base?
Conversation
Not relative to the image size after resizing it to fit the website limits, otherwise we potentially end up scaling them way smaller than the user preference specified.
By introducing a setting to that effect, disabled by default, and preferring to reduce quality instead by default. Reducing JPEG quality is a much faster operation and retains visual quality pretty well, as opposed to scaling an image to some kind of dinky size, so I think it makes sense to enable this by default. Images with alpha transparency will continue to prefer being scaled smaller before punting to JPEG to avoid losing the alpha channel.
It's 1000000 bytes, not 0.9 MiB.
Because the website itself doesn't support alpha transparency. We now always act as if images provided to it don't have alpha, meaning we use the non-alpha resize setting and punt to JPEG immediately if quality reduction is preferred.
Was also about to work on this, glad you did it. I will test it by myself soon and provide devbuild for friends to test. |
I tested it meanwhile, worked for me and resized the images nicely. So I'm happy with how it's working currently, but I'll wait for further comments. |
Okay, so far i encoutered these errors: Im using this image set for testing
This set of images was provided by FatBluDragon from Discord
Please note that all other image scaling settings are set to defaults |
To be able to tell why the heck it's producing images that are larger than the input image.
It was checking the input file size, not the resized image size. However, resizing the image smaller can actually *increase* the size. Now it properly checks the buffer it's actually going to be posting. This should fix mvdicarlo#328.
Fixed the (pre-existing) bug that images get rescaled to a larger size and posted all of the given images without error. |
A few things in here, check the individual commits for more details. The main issue here is that when you post to Bsky, the image gets scaled to a dinky 1000x1000 size, which is a) wrong, because it exceeds the maximum scale amount I set and b) bad, because it could just use a pretty good quality JPEG instead and not lose any size.
So this PR does a few things in that regard.
It takes the maximum scale amount set by the user relative to the original image size, not the size after rescaling the image according to website limits. Presumably this was the intended behavior to begin with, so this is just a bugfix.
Maybe somewhat controversially, it now prefers quality reduction over size reduction by default, at least for images that don't have an alpha channel. Reducing JPEG quality is notably faster than trying a bunch of resizing and, in my opinion, gives better visual quality than having a smaller image. It's a preference, so users that don't want this can still disable it.
It corrects the maximum image size in bytes for Bsky. It was set to 0.9 MiB, but it's really 1000000 bytes. Only a difference of 55 KiB, but hey.
Finally, it marks Bsky as not supporting alpha. If a website sets this flag, the file munger will act accordingly resizing the image as if it didn't have alpha and converting to JPEG more eagerly.
I'll be marking this as tentative, since it could use some feedback and testing first.