Massive inflation of .qrc files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Massive inflation of .qrc files

Scott Harvey
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.

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.

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. 



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Phil Thompson-5
On 24 Dec 2017, at 8:55 pm, Scott Harvey <[hidden email]> 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.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Giuseppe Corbelli
On 12/24/2017 11:38 PM, Phil Thompson wrote:
>> 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.

What would be your recommended approach to create a resource bundle?

--
Giuseppe Corbelli
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Phil Thompson-5
On 3 Jan 2018, at 8:27 am, Giuseppe Corbelli <[hidden email]> wrote:
>
> On 12/24/2017 11:38 PM, Phil Thompson wrote:
>>> 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.
>
> What would be your recommended approach to create a resource bundle?

pyrcc is the only way to create a resource file for Python. The question is, why create a resource file at all?

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Giuseppe Corbelli
On 01/03/2018 10:50 AM, Phil Thompson wrote:
>>>> 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.
>>
>> What would be your recommended approach to create a resource bundle?
>
> pyrcc is the only way to create a resource file for Python. The question is, why create a resource file at all?

First thing that comes to mind is easier distribution in multiple
formats (wheel, frozen...)

--
Giuseppe Corbelli
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Phil Thompson-5
On 3 Jan 2018, at 11:00 am, Giuseppe Corbelli <[hidden email]> wrote:

>
> On 01/03/2018 10:50 AM, Phil Thompson wrote:
>>>>> 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.
>>>
>>> What would be your recommended approach to create a resource bundle?
>> pyrcc is the only way to create a resource file for Python. The question is, why create a resource file at all?
>
> First thing that comes to mind is easier distribution in multiple formats (wheel, frozen...)

I don't think it makes it any easier, see...

http://pyqt.sourceforge.net/Docs/pyqtdeploy/pyrcc.html

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Giuseppe Corbelli
On 01/03/2018 01:19 PM, Phil Thompson wrote:

>> On 01/03/2018 10:50 AM, Phil Thompson wrote:
>>>>>> 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.
>>>>
>>>> What would be your recommended approach to create a resource bundle?
>>> pyrcc is the only way to create a resource file for Python. The question is, why create a resource file at all?
>>
>> First thing that comes to mind is easier distribution in multiple formats (wheel, frozen...)
>
> I don't think it makes it any easier, see...
>
> http://pyqt.sourceforge.net/Docs/pyqtdeploy/pyrcc.html

Sorry but I think I am missing something. Let's say I'm NOT using
pyqtdeploy.
I can deploy a wheel with the resource tree and use pkg_resources api.
With pyinstaller I am forced to use resource-only eggs.
Qt resources system + pyrcc is the only transparent solution I can think.

--
Giuseppe Corbelli
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Phil Thompson-5
On 3 Jan 2018, at 2:31 pm, Giuseppe Corbelli <[hidden email]> wrote:

>
> On 01/03/2018 01:19 PM, Phil Thompson wrote:
>>> On 01/03/2018 10:50 AM, Phil Thompson wrote:
>>>>>>> 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.
>>>>>
>>>>> What would be your recommended approach to create a resource bundle?
>>>> pyrcc is the only way to create a resource file for Python. The question is, why create a resource file at all?
>>>
>>> First thing that comes to mind is easier distribution in multiple formats (wheel, frozen...)
>> I don't think it makes it any easier, see...
>> http://pyqt.sourceforge.net/Docs/pyqtdeploy/pyrcc.html
>
> Sorry but I think I am missing something. Let's say I'm NOT using pyqtdeploy.
> I can deploy a wheel with the resource tree and use pkg_resources api.

As a wheel is expanded to the filesystem I don't see the need for any API to access a data file included in the wheel.

> With pyinstaller I am forced to use resource-only eggs.
> Qt resources system + pyrcc is the only transparent solution I can think.

I've never used pyinstaller.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Pou Belle
In reply to this post by Scott Harvey

Scott Harvey wrote
> 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.
> File            Size
> -------                          -----------
> splash.png      97244
> splash.qrc          86
> splash_qrc.py  402588


Hello Scott,

Compile your splash_qrc.py into a splash_qrc.pyc file, it will become very small again.

Here is what I get on my current project :

File                  Size
Resources (png, jpg) : 124172
resources.qrc :          429
resources_rc.py :      373507
resources_rc.pyc :      89712

The only file that will really be loaded by python (pyc : 89712) is even smaller than the sum of the original files (124172).
pyrcc is making my life a lot easier, I love it.

Cheers.


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Kyle Altendorf
In reply to this post by Giuseppe Corbelli
On 2018-01-03 09:31, Giuseppe Corbelli wrote:

> On 01/03/2018 01:19 PM, Phil Thompson wrote:
>>> On 01/03/2018 10:50 AM, Phil Thompson wrote:
>>>>>>> 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.
>>>>>
>>>>> What would be your recommended approach to create a resource
>>>>> bundle?
>>>> pyrcc is the only way to create a resource file for Python. The
>>>> question is, why create a resource file at all?
>>>
>>> First thing that comes to mind is easier distribution in multiple
>>> formats (wheel, frozen...)
>>
>> I don't think it makes it any easier, see...
>>
>> http://pyqt.sourceforge.net/Docs/pyqtdeploy/pyrcc.html
>
> Sorry but I think I am missing something. Let's say I'm NOT using
> pyqtdeploy.
> I can deploy a wheel with the resource tree and use pkg_resources api.
> With pyinstaller I am forced to use resource-only eggs.
> Qt resources system + pyrcc is the only transparent solution I can
> think.

I may be missing something but I don't recall doing anything with eggs
for my PyInstaller deployed PyQt application.  There's lots of silly
stuff I shouldn't be doing and I assume I'm not handling my data
correctly but I just tell PyInstaller about the files.

https://github.com/altendky/st/blob/2ef9b66edc44ba7ed96ebc5898bf8d3d7ae64adc/installer/pyinstaller.spec#L56
build at:
https://ci.appveyor.com/project/KyleAltendorf/st/build/v0.1.1.post91%20b207

Perhaps if I used whatever the proper Python mechanism is
(`include_package_data` and `MANIFEST.in`?) I wouldn't have to guide
PyInstaller.  I tried it in a minimal PyQt example I made for IRC but I
haven't tried PyInstaller with that yet.

https://github.com/altendky/misc/tree/3c4c17abc4629e4fd4acdd8d4d8ca229ebd00b1f/experiments/basicpyqt5example

Cheers,
-kyle
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Massive inflation of .qrc files

Pou Belle
In reply to this post by Pou Belle
I'm sorry, I don't know why my message appeared with "*' characters everywhere, here it is again :



Scott Harvey wrote
> 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.
> File            Size
> -------                          -----------
> splash.png      97244
> splash.qrc          86
> splash_qrc.py  402588


Hello Scott,

Compile your splash_qrc.py into a splash_qrc.pyc file, it will become very small again.

Here is what I get on my current project :

File                  Size
Resources (png, jpg) : 124172
resources.qrc :          429
resources_rc.py :      373507
resources_rc.pyc :      89712

The only file that will really be loaded by python (pyc : 89712) is even smaller than the sum of the original files (124172).
pyrcc is making my life a lot easier, I love it.

Cheers.


2018-01-04 11:47 GMT+01:00 Pou Belle <[hidden email]>:

Scott Harvey wrote
> 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.
> File            Size
> -------                          -----------
> splash.png      97244
> splash.qrc          86
> splash_qrc.py  402588


Hello Scott,

Compile your splash_qrc.py into a splash_qrc.pyc file, it will become very small again.

Here is what I get on my current project :

File                  Size
Resources (png, jpg) : 124172
resources.qrc :          429
resources_rc.py :      373507
resources_rc.pyc :      89712

The only file that will really be loaded by python (pyc : 89712) is even smaller than the sum of the original files (124172).
pyrcc is making my life a lot easier, I love it.

Cheers.



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt