miracle2k/webassets — pull request #326 by qris (2014-08-19 15:06:02+00:00)
Title: Improve support for binary assets

You may be interested in a new filter that we've developed: [Django-Assets SVG](https://github.com/aptivate/django-assets-svg). It generates optimised PNG files from SVG sources.

We had a lot of difficulty in processing binary files through Django-Assets, mainly because it's assuming in several places that files should be opened in Unicode and written out in UTF-8. Of course a PNG file does not take kindly to this transformation, let alone not being validly encoded in UTF-8 in the first place :)

The main issues that I saw were:

* FileHunk opens files for reading with `encoding='utf-8'`
* merge() concatenates files using a string separator
* FilterTool uses a StringIO to store intermediate data, which tries to combine its buffers as unicode strings, and breaks if they're binary `str` strings.
* MemoryHunk.save() opens files for writing with `encoding='utf-8'`
* There's currently no way to replace any of these parts.

Please could you look into how we can replace these functions when defining our bundles, so that we can process binary files properly? Thanks!