is it duplicated library code in final exe ?

Just starting out? Need help? Post your questions and find answers here.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

is it duplicated library code in final exe ?

Post by moricode »

Zlib provides functions like deflate (compress) and inflate (decompress)

ZIP files often use deflate compression internally to compress individual files
if they worked more or less the same in decode/encode functions ,

then my program use PNG encoder/decoder and also useZIP encoder/decoder

so , my EXE size is huge because they included both function .


can this PNG and ZIP is share use the deflate (compress) and inflate (decompress) function ? so will reduce the redundant binary size ?
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: is it duplicated library code in final exe ?

Post by boddhi »

To the best of my knowledge, the UsePNGImageEncoder() and UsePNGImageDecoder() functions don't compress/decompress PNG images, but only allow this type of image to be written and read.

So, to compress/decompress them in size, you need to use too the appropriate functions provided by the Packer lib or other external lib/program.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: is it duplicated library code in final exe ?

Post by Fred »

It's already shared between libs which use the same components
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: is it duplicated library code in final exe ?

Post by moricode »

In PB 5.72 x86, compiled to final exe size :

Code: Select all


MessageRequester("","")

exe = 5 KB

Code: Select all

UseZipPacker()
MessageRequester("","")

exe = 201 KB

Code: Select all

UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")

exe = 148 KB

Code: Select all

UseZipPacker()
UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")


exe = 303 KB 

so it look like duplicated code in binary

it is clear that has 303 - 148 = 155 KB more ?
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: is it duplicated library code in final exe ?

Post by Demivec »

moricode wrote: Tue May 13, 2025 4:26 am it is clear that has 303 - 148 = 155 KB more ?
Am I wrong or does your math looks a little wonky?

I see 303 KB - (148 KB) - (201 KB - 5 KB) = -41 KB. So combining everything into the exe sized 303 KB seems to save 41 KB.

@Edit: corrected a minor error.
Last edited by Demivec on Tue May 13, 2025 9:15 am, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: is it duplicated library code in final exe ?

Post by Fred »

:mrgreen:
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: is it duplicated library code in final exe ?

Post by moricode »

Demivec wrote: Tue May 13, 2025 5:53 am
moricode wrote: Tue May 13, 2025 4:26 am it is clear that has 303 - 148 = 155 KB more ?
Am I wrong or does your math looks a little wonky?

I see 303 KB - (148 KB - 5 KB) - (201 KB - 5 KB) = -36 KB. So combining everything into the exe sized 303 KB seems to save 36 KB.
so you mean the PNG format placeholder without the deflate (compress) and inflate (decompress) code cause a large binary of 140+KB ?

so to use a PNG function needed 303K in total or just 148KB enough ?

dose this just will work without the zippacker ?

Code: Select all

UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")

exe = 148 KB
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: is it duplicated library code in final exe ?

Post by AZJIO »

You don't need a ZIP for PNGs. You can use PNGGauntlet to compress PNG files as much as possible
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: is it duplicated library code in final exe ?

Post by Fred »

moricode wrote: Tue May 13, 2025 7:43 am
Demivec wrote: Tue May 13, 2025 5:53 am
moricode wrote: Tue May 13, 2025 4:26 am it is clear that has 303 - 148 = 155 KB more ?
Am I wrong or does your math looks a little wonky?

I see 303 KB - (148 KB - 5 KB) - (201 KB - 5 KB) = -36 KB. So combining everything into the exe sized 303 KB seems to save 36 KB.
so you mean the PNG format placeholder without the deflate (compress) and inflate (decompress) code cause a large binary of 140+KB ?

so to use a PNG function needed 303K in total or just 148KB enough ?

dose this just will work without the zippacker ?

Code: Select all

UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")

exe = 148 KB
You just need UsePNGImageEncoder() and UsePNGImageDecoder() to use PNG, why do you want to add the zip lib ? The zip lib large because it use libarchive which handle a lot of file format. But if you use both, it uses a common libzip defalte as both need it, that's why 36KB are saved.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: is it duplicated library code in final exe ?

Post by moricode »

Fred wrote: Tue May 13, 2025 8:33 am

You just need UsePNGImageEncoder() and UsePNGImageDecoder() to use PNG, why do you want to add the zip lib ? The zip lib large because it use libarchive which handle a lot of file format. But if you use both, it uses a common libzip defalte as both need it, that's why 36KB are saved.

it comes to a points that , i want to use PNG , and i want to use the deflate/inflate method to compress the memory buffer (other that image buffer),

so i use UsePNGImageEncoder() and UsePNGImageDecoder() ,
without the zippacker , can i use the PNG deflate/inflate method ?

just like PNGdeflateMemory() and PNGinflateMemory() ? then i do not need Zip lib
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: is it duplicated library code in final exe ?

Post by Fred »

You can already use the deflate zip method if you include PNG, please post a code showing what you are trying to do
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: is it duplicated library code in final exe ?

Post by Demivec »

so you mean the PNG format placeholder without the deflate (compress) and inflate (decompress) code cause a large binary of 140+KB ?

so to use a PNG function needed 303K in total or just 148KB enough ?
[/quote]

it looks like I was off in my math by 5 KB. I've redone it to show how it works a little better.

Looking at what was in each file you compiled it looks like this:

Code: Select all

Program Elements:
A   -------   MessageRequester("","")
B   -------   UseZipPacker()
C   -------   UsePNGImageEncoder()
D   -------   UsePNGImageDecoder()


      Prog_1        Prog_2           Prog_3         Prog_4
         A             A                A              A
                       B                               B
                                        C              C
                                        D              D
 -----------------------------------------------------------
   Size  5 KB        201 KB          148 KB          303 KB
     (A= 5 KB)       196 KB     - A  143 KB     - A  298 KB
                 (B= 196 KB)                    - B  102 KB
                               (C+D= 143 KB)   (C+D= 102 KB)
                                   - 102 KB        - 102 KB
 -----------------------------------------------------------
                                      41 KB extra
Prog_4 had more in it but took up 41 KB less than Prog_3 even though Prog_3 doesn't include UseZipPacker().

Fred and others have given some explanation as to why this might be so.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: is it duplicated library code in final exe ?

Post by moricode »


Result = CompressMemory(*Buffer, Size, *Output, OutputSize [, Plugin [, Level]])
Description

Compress the buffer content into the output buffer. The output buffer length needs to be at least as long as the buffer to compress.
Parameters

*Buffer The memory buffer to compress.
Size The size of the memory to compress.
*Output The memory buffer to store the compressed data.
OutputSize The memory buffer size to store the compressed data.
Plugin (optional) The plugin to use, if more than one packer plugin has been registered. It can be one of the following value:
#PB_PackerPlugin_BriefLZ: use the BriefLZ packer to compress the memory. UseBriefLZPacker() has to be called to register the plugin.
#PB_PackerPlugin_Zip : use the Zip packer to compress the memory. UseZipPacker() has to be called to register the plugin.
#PB_PackerPlugin_LZMA : use the LZMA packer to compress the memory. UseLZMAPacker() has to be called to register the plugin.



CompressMemory() ---> can i use the #PB_PackerPlugin_PNG or #PB_PackerPlugin_Deflate ?

since the PNG is already Deflate/inflate enable
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: is it duplicated library code in final exe ?

Post by moricode »

it doesn't matter how the math is ,
when i UsePNGEncode() and UsePNGDecoder() , could i use the Deflate methor in CompressMemory() function ?

in Doc help file , the CompreeMemory() only support #PB_PackerPlugin_BriefLZ , #PB_PackerPlugin_Zip , #PB_PackerPlugin_LZMA

how to use the deflate/inflate method in CompressMemory() ?

Thanks .
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: is it duplicated library code in final exe ?

Post by jacdelad »

AZJIO wrote: Tue May 13, 2025 8:24 am You don't need a ZIP for PNGs. You can use PNGGauntlet to compress PNG files as much as possible
OxiPNG ist even better.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply