Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial handling of "background-image" property #6

Open
olivierphi opened this issue May 17, 2011 · 5 comments
Open

Partial handling of "background-image" property #6

olivierphi opened this issue May 17, 2011 · 5 comments
Labels

Comments

@olivierphi
Copy link

SpriteMapper successfully detects the pictures in "background-image" CSS properties and adds them in the spritesheet, but it "forgets" to handle the "background-image" in the resulting CSS file : they are not updated to target the spritesheet PNG file, and no "background-position" is set.
The "background" properties in the same file are OK, though...

A solution could be replacing "background-image: " with "background :" in the CSS file ; but they are some cases where you really need to use "background-image " instead of "background".

@lericson
Copy link
Member

Well, initially the goal was to cover both background-image and background. I just never got around to implementing the latter, because of complications involved and deadlines. So the proper thing to do here is to either a) file a new ticket saying we should support background-image and retract the current half-assed implementation, or b) fix it.

@lericson
Copy link
Member

To elaborate: the problem is that you'd need to emit additional CSS syntax, not just modify existing. While possible, it's a different beast. You'll see what I mean if you look at the replacing code, https://github.com/yostudios/Spritemapper/blob/master/spritecss/replacer.py#L27

@olivierphi
Copy link
Author

Ok, I see what you mean : the CSS modifications seem to be simple "search/replace" on background CSS properties. Covering background-image would require the setting of an additionnal background-position property in the CSS block.

Unfortunately, I'm not a python coder, therefore I can't even try to fix it myself...

Thanks for your answer !

@schiebs
Copy link

schiebs commented May 18, 2011

I'm having trouble getting sitemapper to work at all.
If I use the full background property, e.g.:

background: transparent url(images/some.gif) no-repeat scroll 0 0;

I get a sm_style.css, that's identical to style.css, and no sprite image output.

As mentioned here, if I separate the background properties into background-color, background-image, etc, sitemapper doesn't handle it.

In an attempt to get something out, I tried simply:

background: url(images/some.gif);

on a couple rules, and I get the error

File "C:\Python27\lib\site-packages\spritecss\png.py", line 1667, in validate_signature
  raise FormatError("PNG file has invalid signature.")
spritecss.png.FormatError: FormatError: PNG file has invalid signature.

I believe spritecss.png is the sprite image file you are creating.
I have tried this on Windows XP and Windows Server Enterprise systems using Python 2.7.

@lericson
Copy link
Member

Spritemapper only handles background, and cannot handle GIF images. If you feel this was not clear from the documentation, please file an issue suggesting where we should tell people about it.

No, spritecss.png is a module path. It is complaining that it cannot open the given file, because it is not a PNG. Please do not hijack issues like this.

Edit: The reason your first declaration doesn't work is that it specifies background positions; these are probably not sprites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants