matthiaskrgr / flifcrush

simple crusher tries to reduce FLIFs in size by recompressing them with different parameters
12 stars 6 forks source link

porting to c++ - help wanted #24

Open StephanBusch opened 8 years ago

StephanBusch commented 8 years ago

That script is ported to c++ and I need you help: could you please provide me how to use that python script and main structure of script?

matthiaskrgr commented 8 years ago

On linux, you can tell the script where the flif binary is executed via export FLIF=/path/to/flif The script will then use that binary. "main.py ." or "main.py file.png" or "main.py dir" will try to conver the current directory, the passed directory (both recursively) or only a single file.

What I roughly do is taking the different encode options of flif and try them one by one. I start with some default values and try to modify the parameters one by one. I try out values from x to y, remember the combination of encoding args that got the smallest output file and use it when I move to the next encode option. Like this I iterate through the encode options several times until the image no longer gets smaller.

This bruteforce attempt can be very inefficient, one could argue I basically don't know what I am doing. :)

If you plane to have a crusher in c++, I highly recommend using flif functions. For example it should be sufficient to read-in the original file (e.g. png) only once and cache it. (flifcrush would call the flif binary a couple thousand times which means the source image would be read-in every time).

Furthermore it should be possible to directly access and modify the maniac tree instead of just feeding in different parameters and checking if the tree eventually changes and gets smaller.

So using c++ opens up a much more efficient but also different approach. I have not dug very deeply into how the maniac tree is generated, so I don't know any great details. The chat-channel https://gitter.im/FLIF-hub/FLIF might be able to provide further information.

necros2k7 commented 7 years ago

+1