CSS Sprites Auto Generation

    It happened. Long sleepless nights were not in vain and the thought stated by Vadim aka pepelsbey took on more or less physical shape.

    sprites.webo.in (raw-raw alpha version) - the name, in fact, speaks for itself. We enter the URL of the CSS file - at the output we get an archive with a minimized (no sorting of selectors, just basic minimization) CSS file and a bunch of fresh sprites. Is it great?

    The CSS Sprites generation algorithm has already been outlined in general terms. Along the way, I had to clarify the positioning for the- no-repeatpictures: some of them need to be placed with a “ladder” (for which the block size is not set), and some can be shoved as necessary (if the dimensions are precisely determined).

    For vkontakte.ru, it turned out right awaysuch a sample .

    The version is raw, some cases are not processed, some are processed incorrectly. Accordingly, I want to hear the largest possible number of cases when some kind of "garbage" occurs. Immediately make a reservation that sprites are not created in some cases. Firstly, if a sprite is already used as a background (because it’s not possible to parse such an image in the case of a “ladder”). Secondly, if the total number of images that can be combined in the corresponding group is only 1. Thirdly, if the image is an animation. Fourth, if it was not possible to establish the correct one repeatfor the element and the dimensions were not set (then the image will be repeated in all directions in an unknown volume - and it cannot be combined with anything else).

    The most interesting, of course, is how to solve the problem of arranging images in an "arbitrary" sprite - but more about that next time (when the algorithm is refined a bit, the latest version is always available in the repository ).

    And finally, the stand-alone version will be included in the very near future in Web Optimizer (Web Optimizer) - an application aimed at automating client optimization. You can always download it at: code.google.com/p/web-optimizator/ .

    In general, comments, observations, test cases, the desire to help with your hands - all this is welcome - sprites.webo.in

    PS For the last week a couple of invites have been formed - if you need to help good people, write in private

    Also popular now: