Has anyone successfully used smartsprites to generate sprites for use on high dpi displays? (e.g. http://brianistech.wordpress.com/2011/05/11/ios-retina-sprites/)We're using it for regular sprites without issues, but I'm having trouble getting it to work with my 2x images; I think the main issue is the background-position should be the adjusted by the ratio between the specified background-size and the actual sprite size. Or, to put it more simply, when dealing with images that are twice the size, the background position should be 50% of what it is in order for the scaling to work properly.I'll probably fork the code and take a stab at this if no one else has figured it out, but I wanted to ask first.Dan--
You received this message because you are subscribed to the Google Groups "SmartSprites CSS Sprite Generator Users and Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smartsprites-css-sprit...@googlegroups.com.
To post to this group, send email to smartsprites-css...@googlegroups.com.
Visit this group at http://groups.google.com/group/smartsprites-css-sprite-generator?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Dan,There's no support for Retina sprites, yet. A patch/fork would be most welcome (I'm swamped with other work...)!Thanks,Stanislaw
On Wed, Feb 13, 2013 at 11:54 PM, Dan Polivy <dan.p...@gmail.com> wrote:
Has anyone successfully used smartsprites to generate sprites for use on high dpi displays? (e.g. http://brianistech.wordpress.com/2011/05/11/ios-retina-sprites/)We're using it for regular sprites without issues, but I'm having trouble getting it to work with my 2x images; I think the main issue is the background-position should be the adjusted by the ratio between the specified background-size and the actual sprite size. Or, to put it more simply, when dealing with images that are twice the size, the background position should be 50% of what it is in order for the scaling to work properly.I'll probably fork the code and take a stab at this if no one else has figured it out, but I wanted to ask first.
Dan--
You received this message because you are subscribed to the Google Groups "SmartSprites CSS Sprite Generator Users and Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smartsprites-css-sprite-generator+unsubscribe@googlegroups.com.
To post to this group, send email to smartsprites-css-sprite-gene...@googlegroups.com.
Apache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)
Maven home: c:\Projects\apache-maven-3.0.4
Java version: 1.7.0_13, vendor: Oracle Corporation
Java home: C:\Program Files\java\jdk1.7.0_13\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
I was able to add a new directive (sprite-scale) to the sprite image directive, and have successfully generated a high DPI compatible sprite with our existing stylesheet! I haven't used Java in over 10 years, so getting the build going was a little complicated, but in the end it wasn't so bad.
The idea is that you could specify your desired scaling factor PER SPRITE IMAGE, and then all images in that sprite will be processed given that scale ratio. That means the background-position will be adjusted by the scale, and if the scale is not 1, a background-size property will also be emitted.
I initially implemented this value as a float -- but am thinking about changing it to an int. I'm assuming most folks will simply want to double their images vs use an arbitrary scale factor. What are your thoughts on this?
Also, in order to get my newly forked/cloned repository to build on my machine, I had to make a few changes to the test code. Here's my version information:Apache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)
Maven home: c:\Projects\apache-maven-3.0.4
Java version: 1.7.0_13, vendor: Oracle Corporation
Java home: C:\Program Files\java\jdk1.7.0_13\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"1) I was getting an ambiguous reference error on the Message class constructor. I fixed this by removing the "convenience" constructor (the one with fewer parameters), and adding in the necessary parameters to the handful of calls that needed them. Is this a JDK/compiler issue?
2) Two of the tests (absolute-image-url and non-default-output-dir) needed a few tweaks to the css files. For both, the MD5 hash in the expected file was different than what was generated. I removed the md5 hash as it appeared you wanted to deprecate that directive in the future. Also, the non-default-output-dir needed a tweak to not delete the original source images when it cleans up.Are these two issues known with the current state of the codebase, or somehow related to my configuration?
Is there any way to build the install package using mvn? I haven't been able to figure that one out yet. Though I was able to manually piece together all of the dependencies to get it to work instead of my existing installation for another project.
Once I get some feedback on the float/int thing, I can commit my code and send it back your way.
The idea is that you could specify your desired scaling factor PER SPRITE IMAGE, and then all images in that sprite will be processed given that scale ratio. That means the background-position will be adjusted by the scale, and if the scale is not 1, a background-size property will also be emitted.That sounds reasonable. My thinking is that in most real-world scenarios it wouldn't make much sense to mix different scale images in one sprite, right? You either have Retina and use 2x images or not and then use the 1x ones.
I initially implemented this value as a float -- but am thinking about changing it to an int. I'm assuming most folks will simply want to double their images vs use an arbitrary scale factor. What are your thoughts on this?Actually, some devices have the 1.5x pixel ratio, so float is the way to go, I think.
1) I was getting an ambiguous reference error on the Message class constructor. I fixed this by removing the "convenience" constructor (the one with fewer parameters), and adding in the necessary parameters to the handful of calls that needed them. Is this a JDK/compiler issue?I'm seeing this issue too, it must be a compiler bug fixed in JDK7. Ultimately, I'll probably create static factory methods in Message and disambiguate by method name, but feel free to leave your current approach, I can fix that later.
2) Two of the tests (absolute-image-url and non-default-output-dir) needed a few tweaks to the css files. For both, the MD5 hash in the expected file was different than what was generated. I removed the md5 hash as it appeared you wanted to deprecate that directive in the future. Also, the non-default-output-dir needed a tweak to not delete the original source images when it cleans up.Are these two issues known with the current state of the codebase, or somehow related to my configuration?I noticed you created a fork, so if you push your changes to your branch, I can pull then and take a look at the changes.
If you do: mvn -Prelease clean package, you should see the release ZIP in the target/ directory.
Please go ahead, I'll bring your patch in and make an official release, it really high time...Thanks a log for your contribution!
That sounds reasonable. My thinking is that in most real-world scenarios it wouldn't make much sense to mix different scale images in one sprite, right? You either have Retina and use 2x images or not and then use the 1x ones.While I haven't tried multiple scale values in the same sprite, in theory I think it might work; you'd just have to be sure to emit the properly scaled background-position and background-size tags for each image based on its individual scale ratio. But, I don't think there's much benefit to this approach. The main reason you'd keep the 2x images separate is because they're bigger, and you don't want folks to download them if they don't actually need them--so my thinking is that most folks will want to keep sprites separate based on the scale ratio. If that assumption proves to be incorrect, it shouldn't be that hard to add a per-reference directive to override the scale.
I initially implemented this value as a float -- but am thinking about changing it to an int. I'm assuming most folks will simply want to double their images vs use an arbitrary scale factor. What are your thoughts on this?Actually, some devices have the 1.5x pixel ratio, so float is the way to go, I think.True -- but it's more likely folks will stick to a single ratio (e.g. 2x) and just let the browsers scale as appropriate. More pixels never hurt, except the download size :) But either way, I left it as a float. I also put in some log warnings so that if any of the calculated dimensions (per-reference or per-sprite) are fractional, smartsprites will let you know. That generally means your scaling isn't correct and the resulting image won't look exactly right.
Sounds good. I cleaned up my changes, commited to GitHub, and opened a pull request for you to review. Let me know if you have any questions. I didn't update the documentation, though.
--
You received this message because you are subscribed to a topic in the Google Groups "SmartSprites CSS Sprite Generator Users and Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/smartsprites-css-sprite-generator/wqw5rtRIGbA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to smartsprites-css-sprit...@googlegroups.com. Visit this group at http://groups.google.com/group/smartsprites-css-sprite-generator.