4 ms·
>After all these years there still isn't a format that can save a Photoshop layer and represent non-trivially blended transparency correctly (closest you can ge
by mistercow 13y ago
>After all these years there still isn't a format that can save a Photoshop layer and represent non-trivially blended transparency correctly (closest you can get is images wrapped in SVG with filters, uhh).
There are other ways you can hack around it. One is to save the JPEG at double width and save the alpha channel as a gray scale image on the right, and then use css masks for webkit, canvas for firefox, and CSS filters for IE to add the alpha channel when the page renders. A similar technique can be used to do transparent video: http://jakearchibald.com/scratch/alphavid/ http://jakearchibald.com/scratch/alphavid/
For better results, you actually want to pad the right side of the non-alpha image to a multiple of 8 so that you hit JPEG block boundaries. Then you repeat the edge pixels so that you don't get artifacts at the edges.
Handling artifacts from transparent pixels turning non-transparent is a little trickier, but one strategy is to apply a gaussian blur (radius 8) to the original image, discard the alpha channel, and then fill all completely transparent pixels in the original with the blurred version.