kamsar / Dianoga

An automatic image optimizer for the Sitecore media library.
Other
104 stars 45 forks source link

Serving optimized images to cdn #6

Closed stevenwr23 closed 8 years ago

stevenwr23 commented 8 years ago

Hi, we are serving images from a cdn, so we need to always have optimized images on the first request. Can you add back the OptimizeImage class so we can choose between sync/async?

kamsar commented 8 years ago

That's a good idea. It may take a bit for me to get to it, but it shouldn't be too hard to do.

kamsar commented 8 years ago

This will return as an option in 3.0: https://github.com/kamsar/Dianoga/tree/3.0/src/Dianoga/Invokers/GetMediaStreamSync

kamsar commented 8 years ago

Closing this. 3.0b2 is on NuGet right now, and the README in the 3.0 branch is up to date. Consider it an RC at this point; I'll be using it for a bit before we throw out the final release.

stevenwr23 commented 8 years ago

For the sync option, I came with the following issue:

  1. The optimizer runs
  2. For some reason the optimizer fails (the output is bigger, error on the program, etc), so the result is dropped
  3. An empty image is stored on the cache.

I think this happens because the original stream is now on the end position, and we can't reset the position because the stream is not seekable. I fixed it by making a copy of the stream and returning it if the output is dropped. Let me know if you need more details on this.