rayrobdod / png-inflate

A clean filter for git that decompresses png images
Apache License 2.0
2 stars 0 forks source link

Check whether this filter does result in a smaller git repository #1

Open rayrobdod opened 5 years ago

rayrobdod commented 5 years ago

I mean, that is the only practical use of this I've thought of so far.

Remember to disable the computer's sleep mode before trying this again.

Maybe also compare against a tree-filter that recompresses with pngout, or one that uses both pngout and this.

https://github.com/eliatlarge/FEMultiPlayer-V2 and https://github.com/thatswhatyouget/tpp-progress are probably two repositories with a lot of images (even if the images are dwarfed by the music files and generated js files respectively), but their images are all poorly compressed anyway. Maybe one of the pret ones.

#! powershell -File
$CACHE=$env:TMP + '\.hash_inflate\'
$FILTER='C:\Users\Raymond\AppData\Local\Temp\rust\release\png_inflate.exe'

ForEach ($file in $args) {
    $hash = $(Get-FileHash -LiteralPath $file).Hash
    $hashpath = $($CACHE + $hash)
    if ($(Test-Path -LiteralPath $hashpath)) {
        Copy-Item -LiteralPath $hashpath -Destination $file -Force
    } else {
        &"$PNG_FILTER" $file $hashpath
        Copy-Item -LiteralPath $hashpath -Destination $file -Force
    }
}
Set-ExecutionPolicy Unrestricted -Scope Process
cd $env:TMP
git clone https://github.com/thatswhatyouget/tpp-progress.git tpp-progress6
cd tpp-progress6
&git filter-branch --tree-filter "find -name '*.png' -exec C:/Users/Raymond/AppData/Local/Temp/filter.ps1 {} +"
cd ..
git clone file://C:/Users/Raymond/AppData/Local/Temp/tpp-progress6 tpp-progress7
# Then check the sizes of the `.git` drectories of a fresh clone of the original repository with the newly produced one
rayrobdod commented 5 years ago

In theory, the benefit here is that this allows git to perform delta compressions. However, apparently git by default will not attempt any delta compression on any blob with a size greater than 512Mb. Which, at 32 bits per pixel is about a 1100-pixel square image. Not that most of the images I've seen in a repository are either larger in physical size or 32 bits per pixel.

rayrobdod commented 4 months ago

With pret/pokepinball (with master on 69a220a9efce3939147b8086af4bee3363c9f10f):

All variants have 6253 items after a git gc --aggressive --prune=NOW, which is a basic check that nothing was discarded