[PyQt] Massive inflation of .qrc files
phil at riverbankcomputing.com
Sun Dec 24 22:38:21 GMT 2017
On 24 Dec 2017, at 8:55 pm, Scott Harvey <bundito at gmail.com> wrote:
> Hi all, and happy holidays!
> I've noticed that compiling a .qrc file into a qrc.py file results in a massive increase in size, especially when containing an image.
> I've got two, a big one that holds all the textures and graphics for my main app. I've got another one I use for a quick splash screen.
> It holds one image and I make sure it loads only what's necessary, displays itself, then the rest of the app continues to load. However, here's some details:
> File Size
> ------- -----------
> splash.png 97244
> splash.qrc 86
> splash_qrc.py 402588
> If you look in the .py file, it's got a ton of hexadecimal values, which I'm guessing form the bytecode for the image. Uncompressed? There's supposedly a "-compress" option for pyrcc5, but none of the values (1 through 9) seem to make a difference. I can load the .png file directly to a QPixmap (e.g. not through a resource file), but this fails when I compile my app with PyInstaller.
The -compress option is broken. It is fixed in the current snapshot.
> Obviously, my interest is in getting my splash screen up as quickly as possible while the rest of the app loads. But when I've got to suck in 400Kb for a 97Kb image, the point is kind of lost.
pyrcc converts binary data into Python source code so it is always going to be greater and slower to load.
> I've tried putting "splash.hide()" as late in the execution order as possible, but it's still fast. I'm not going to cheat and use "sleep()" :-)
> Does anyone have any insight? I can reduce the quality of the image (since it's shown so briefly), but if the resulting resource file is so large, there's not much point. And 97Kb is hardly a large image.
Using pyrcc is rarely a good idea.
More information about the PyQt