Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rayrobdod opened this issue Dec 30, 2018 · 2 comments
Open
Assignees

Comments

@rayrobdod
Copy link
Owner

rayrobdod commented Dec 30, 2018

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 rayrobdod self-assigned this Dec 30, 2018
@rayrobdod
Copy link
Owner Author

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
Copy link
Owner Author

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

  • The original repository has a size-pack of 2769
  • Using filter-branch with pngout has a size-pack of 2754 (although pngout's algorithm doesn't seem to work well with tiny, 2-bit-depth images, resulting in a lot of Unable to compress further: copying original file)
  • Using filter-branch with png-inflate has a size-pack of 2712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant