Skip to content

Save surface to file efficiently #121

@Beuc

Description

@Beuc

Hi,

While experimenting with generating low-res (highly pixellated through renpy.display.module.pixellate) image placeholders for RenPyWeb with on-demand resource download, generated from the Laucher, I needed an efficient way to save such placeholders on disk (for inclusion in game.zip, downloaded on game startup).

The JPG function is not well suited for this: even with a 0 quality the file size is still pretty high compared to other options.

The PNG function works but does not compare with e.g. GIMP or ImageMagick wrt size efficiency (which requires some PNG line filters heuristic and/or brute-force AFAIU). In addition, it does not support 8-bit colors which would help in this context.

There is no WEBP support, and my tests indicate that this format would be more size-efficient for saving such placeholders on disk. So adding WEBP support to pygame_sdl2.image.save would help.

I may or may not find another trick to save image placeholders efficiently (I plan to experiment with shrinking+scaling back).
I'm tentatively posting this to know whether WEBP saving support would be welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions