开发者

Sprite height limitation for CSS images?

开发者 https://www.devze.com 2022-12-18 20:32 出处:网络
I\'m making a sprite and its reaching about 4000px in height. Is there a 开发者_StackOverflow社区general size for maximum sprite height that is used within the graphics design community?Browsers will

I'm making a sprite and its reaching about 4000px in height. Is there a 开发者_StackOverflow社区general size for maximum sprite height that is used within the graphics design community?


Browsers will have to decompress (and keep in memory) the whole image even if you only use very few sprites in it, and even if most of the image is blank/white. For a desktop client you've only missed an occasion to be a good citizen by using too much memory (and browser are already sucking a lot of memory). For some mobile client (eg. IPhone for files over 25k after degzipping), it can be more problematic, the image won't be cached at all, thus it may be better to have 2 files <25k and two HTTP request than one >25k file and a single request never cached.

Last problem, PNG compression is line-based, there is less overhead in having wide images than tall ones (though too wide could be theoretically bad in some case, since you can have only one prediction filter type per line).

Oh and also, with too much spriting, you may end with way too much different colors in the same image, and miss the opportunity for decent paletted image. Testing all combinations of this is tedious, but if you can, grouping your sprites by main colors of gradients is a good heuristic (since gradients/blur needs many different colors).


I don't think the focus should be on how big the sprite is physically (width x height) but rather how big the sprite file size is and ask yourself the question if it would be worth splitting the sprite into multiple sprites.

Quite often we split our sprites based on color so have sprites that are predominantly blue or red or yellow. That way we get smoother gradients and overall image quality while keeping image file sizes down

0

精彩评论

暂无评论...
验证码 换一张
取 消