swift-snapshot-testing icon indicating copy to clipboard operation
swift-snapshot-testing copied to clipboard

Reduce reference images' file sizes

Open tanwei0319 opened this issue 4 years ago • 2 comments

Just curious if anyone here uses any strategy to minimize the increase in repo size due to the reference images stored. For scrollable views I'm getting image sizes as big as 1.2MB, trying to find a way to minimize this. Tried to tinify the images but the diffing will fail because there are byte differences when images are tinified.

tanwei0319 avatar May 27 '20 07:05 tanwei0319

I think the default strategy for storage is to use PNG, which is lossless (as it needs to be), but is best at compressing large, flat color areas. If you have photos, you might consider replacing them (just when doing snapshot tests) with flat colors.

Another approach might be to snapshot small portions of your UI, rather than a whole screen at once.

Unfortunately, I think the file sizes that come with lossless compression are a cost of doing business with snapshot tests. :-P

SeanMcTex avatar Nov 02 '20 17:11 SeanMcTex

Related: https://github.com/pointfreeco/swift-snapshot-testing/pull/467

stephencelis avatar Aug 16 '21 21:08 stephencelis