SmartSprites

Duplicate fragments in sprite images

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 0.2.4
  • Component/s: None
  • Description:
    Hide

    Motivation

    Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

    Implementation

    Within each sprite image, there should be exactly one individual image per one sprite reference. Equal sprite references collected across different locations in a CSS file or different CSS files should point to the same sprite and individual image within the sprite. Sprite references should be considered equal if they refer to the same sprite (equal sprite-ref) and have equal bitmap renderings. In particular, equal bitmaps will be produced for equal sprite-alignment and sprite-margin-* properties, but when further sprite reference properties are added, the same rendering may be achieved by different sets of properties.

    Discussion

    The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:

    div#id1,
    div.logo,
    ul > li > div.x {
      background-image: url("../img/logo.png"); /** sprite-ref: sprite */
    }

    Until this duplicate removal is implemented, the above should work as a workaround.

    Show

    Motivation

    Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

    Implementation

    Within each sprite image, there should be exactly one individual image per one sprite reference. Equal sprite references collected across different locations in a CSS file or different CSS files should point to the same sprite and individual image within the sprite. Sprite references should be considered equal if they refer to the same sprite (equal sprite-ref) and have equal bitmap renderings. In particular, equal bitmaps will be produced for equal sprite-alignment and sprite-margin-* properties, but when further sprite reference properties are added, the same rendering may be achieved by different sets of properties.

    Discussion

    The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:
    div#id1,
    div.logo,
    ul > li > div.x {
      background-image: url("../img/logo.png"); /** sprite-ref: sprite */
    }
    Until this duplicate removal is implemented, the above should work as a workaround.
  1. smartsprites.zip
    (3.59 MB)
    Kanu Dialani
    03/Sep/09 11:00 PM

Activity

Stanisław Osiński made changes - 29/Jul/08 08:34 PM
Field Original Value New Value
Fix Version/s 0.2 [ 10053 ]
Fix Version/s 0.1.1 [ 10080 ]
Stanisław Osiński made changes - 17/Sep/08 08:14 PM
Fix Version/s 0.2 [ 10053 ]
Fix Version/s 0.3 [ 10090 ]
Stanisław Osiński made changes - 25/Jul/09 11:27 AM
Original Estimate 4h [ 14400 ]
Remaining Estimate 4h [ 14400 ]
Description If an image has more than one reference in the original CSS, it will be also included multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once. h3. Motivation

Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

h3. Discussion

The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:

{code}
div#id1,
div.logo,
ul > li > div.x {
  background-image: url("../img/logo.png"); /** sprite-ref: sprite */
}
{code}

Until this duplicate removal is implemented, the above should work as a workaround.
Hide
Kevin Vanderbeken added a comment - 03/Sep/09 05:01 PM

I just thought i'd raise why this is still a very valid and important feature request.

The problem here arises because for organisational purposes on large or multi-part sites such as ours, we have separated files for different application components... such as our movie news and our tv guides sections of the site.

These are kept in separate files for easy compartmental workflow of the team as well as reducing file size of all css when minified on the fly by the server. If image references are shared between css files (h3 or h4 decorations, gradients, etc) because of common styling, then the above way of writing code isn't applicable, because of the split files.

eg:
Movies css:
.movies-header { background-image: url("../img/deco.png"); /** sprite-ref: sprite */ }

TV css:
.tv-header { background-image: url("../img/deco.png"); /** sprite-ref: sprite */ }

An inconvenient work around could be forced with an additional css file which overrides selectors with the applicable background image of all the separate css files and defines all the backgrounds there. Like "backgrounds-all-over-the-site.css". This is however, highly impractical and a nightmare to manage!

Show
Kevin Vanderbeken added a comment - 03/Sep/09 05:01 PM I just thought i'd raise why this is still a very valid and important feature request. The problem here arises because for organisational purposes on large or multi-part sites such as ours, we have separated files for different application components... such as our movie news and our tv guides sections of the site. These are kept in separate files for easy compartmental workflow of the team as well as reducing file size of all css when minified on the fly by the server. If image references are shared between css files (h3 or h4 decorations, gradients, etc) because of common styling, then the above way of writing code isn't applicable, because of the split files. eg: Movies css: .movies-header { background-image: url("../img/deco.png"); /** sprite-ref: sprite */ } TV css: .tv-header { background-image: url("../img/deco.png"); /** sprite-ref: sprite */ } An inconvenient work around could be forced with an additional css file which overrides selectors with the applicable background image of all the separate css files and defines all the backgrounds there. Like "backgrounds-all-over-the-site.css". This is however, highly impractical and a nightmare to manage!
Hide
Stanisław Osiński added a comment - 03/Sep/09 07:30 PM

Hi Kevin,

The same point has been made on the discussion group, moving to 0.2.4 release and increasing priority.

S.

Show
Stanisław Osiński added a comment - 03/Sep/09 07:30 PM Hi Kevin, The same point has been made on the discussion group, moving to 0.2.4 release and increasing priority. S.
Stanisław Osiński made changes - 03/Sep/09 07:30 PM
Priority Minor [ 4 ] Major [ 3 ]
Fix Version/s 0.2.4 [ 10135 ]
Fix Version/s 0.3.0 [ 10090 ]
Stanisław Osiński made changes - 03/Sep/09 08:48 PM
Description h3. Motivation

Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

h3. Discussion

The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:

{code}
div#id1,
div.logo,
ul > li > div.x {
  background-image: url("../img/logo.png"); /** sprite-ref: sprite */
}
{code}

Until this duplicate removal is implemented, the above should work as a workaround.
h3. Motivation

Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

h3. Implementation

Within each sprite image, there should be exactly one individual image per one sprite reference. Equal sprite references collected across different locations in a CSS file or different CSS files should point to the same sprite and individual image within the sprite. Sprite references should be considered equal if all of their properties are equal. Currently, this includes {{sprite-ref}}, {{sprite-alignment}} and {{sprite-margin-*}}. In the future, the newly added properties that affect the way the image is rendered within the sprite, such as {{sprite-width}} and {{sprite-height}}, should also be considered during equality testing.

h3. Discussion

The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:

{code}
div#id1,
div.logo,
ul > li > div.x {
  background-image: url("../img/logo.png"); /** sprite-ref: sprite */
}
{code}

Until this duplicate removal is implemented, the above should work as a workaround.
Stanisław Osiński made changes - 03/Sep/09 09:13 PM
Original Estimate 4h [ 14400 ] 6h [ 21600 ]
Description h3. Motivation

Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

h3. Implementation

Within each sprite image, there should be exactly one individual image per one sprite reference. Equal sprite references collected across different locations in a CSS file or different CSS files should point to the same sprite and individual image within the sprite. Sprite references should be considered equal if all of their properties are equal. Currently, this includes {{sprite-ref}}, {{sprite-alignment}} and {{sprite-margin-*}}. In the future, the newly added properties that affect the way the image is rendered within the sprite, such as {{sprite-width}} and {{sprite-height}}, should also be considered during equality testing.

h3. Discussion

The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:

{code}
div#id1,
div.logo,
ul > li > div.x {
  background-image: url("../img/logo.png"); /** sprite-ref: sprite */
}
{code}

Until this duplicate removal is implemented, the above should work as a workaround.
h3. Motivation

Currently, if an image has more than one reference in the original CSS, SmartSprites will include it multiple times in the sprite image. Ideally, if one individual image is added many times to one sprite image, it should appear in it only once.

h3. Implementation

Within each sprite image, there should be exactly one individual image per one sprite reference. Equal sprite references collected across different locations in a CSS file or different CSS files should point to the same sprite and individual image within the sprite. Sprite references should be considered equal if they refer to the same sprite (equal {{sprite-ref}}) and have equal bitmap renderings. In particular, equal bitmaps will be produced for equal {{sprite-alignment}} and {{sprite-margin-*}} properties, but when further sprite reference properties are added, the same rendering may be achieved by different sets of properties.

h3. Discussion

The reason I've not stumbled upon this limitation in my previous SmartSprites-based designs is that I'd usually remove the duplication on the CSS code level, i.e. collapse many rules that used the same image like this:

{code}
div#id1,
div.logo,
ul > li > div.x {
  background-image: url("../img/logo.png"); /** sprite-ref: sprite */
}
{code}

Until this duplicate removal is implemented, the above should work as a workaround.
Remaining Estimate 4h [ 14400 ] 6h [ 21600 ]
Stanisław Osiński made changes - 03/Sep/09 10:07 PM
Status Open [ 1 ] In Progress [ 3 ]
Kanu Dialani made changes - 03/Sep/09 11:00 PM
Attachment smartsprites.zip [ 10161 ]
Hide
Stanisław Osiński submitted changeset 3676 to carrot2 (34 files) - 05/Sep/09 05:37 PM

SMARTSPRITES-18: removing duplicate fragments from sprite images

Show
Stanisław Osiński submitted changeset 3676 to carrot2 (34 files) - 05/Sep/09 05:37 PM
Stanisław Osiński logged work - 05/Sep/09 05:46 PM
  • Time Worked:
    6h 5m
     
    Implementation, refactoring, unit tests.
Stanisław Osiński made changes - 05/Sep/09 05:47 PM
Time Spent 6h 5m [ 21900 ]
Hide
Stanisław Osiński added a comment - 05/Sep/09 05:59 PM

Implemented in trunk, binaries available from:

http://download.csssprites.org/smartsprites-0.2.4-dev.zip

Show
Stanisław Osiński added a comment - 05/Sep/09 05:59 PM Implemented in trunk, binaries available from: http://download.csssprites.org/smartsprites-0.2.4-dev.zip
Stanisław Osiński made changes - 05/Sep/09 05:59 PM
Resolution Fixed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]
Hide
Stanisław Osiński added a comment - 05/Sep/09 06:08 PM

Hi Kanu,

Just for your reference, I implemented the duplicate removal in a slightly different way than suggested in your patch. Instead of comparing individual image paths, I'm comparing the bitmaps individual sprite references produce. This way, even if the same image has two different file names, it will be included in the sprite only once. More importantly, this method correctly takes into account the individual image's margins and other properties I'll be introducing e.g. in: SMARTSPRITES-39. Therefore, beware with your original version: if you have two references to the same image differing only by margins (sprite-margin-*), these will be incorrectly linked to the same image within sprite, though in fact they should produce two different images within the sprite.

S.

Show
Stanisław Osiński added a comment - 05/Sep/09 06:08 PM Hi Kanu, Just for your reference, I implemented the duplicate removal in a slightly different way than suggested in your patch. Instead of comparing individual image paths, I'm comparing the bitmaps individual sprite references produce. This way, even if the same image has two different file names, it will be included in the sprite only once. More importantly, this method correctly takes into account the individual image's margins and other properties I'll be introducing e.g. in: SMARTSPRITES-39. Therefore, beware with your original version: if you have two references to the same image differing only by margins (sprite-margin-*), these will be incorrectly linked to the same image within sprite, though in fact they should produce two different images within the sprite. S.
Stanisław Osiński made changes - 05/Sep/09 06:08 PM
Remaining Estimate 6h [ 21600 ] 0h [ 0 ]
Hide
Stanisław Osiński added a comment - 05/Sep/09 08:00 PM

Hi Kanu,

1) removes duplicate images. creates background-position with the same co-ordinates for same images
2) added parameter to copy non annotated CSS files.
3) added parameter to process/ignore smartsprite annotations.

I've implemented point 1) in a slightly different way, but I have a question about the use case for 2) and 3). I'm assuming that you're using a combination of these two options (copy non-annotated CSS files + ignore annotations) to simply copy your design files from the source location to the output dir? If so, maybe a simple Ant copy task, possibly with some mappers (http://ant.apache.org/manual/CoreTypes/mapper.html) would do instead?

Thanks,

S.

Show
Stanisław Osiński added a comment - 05/Sep/09 08:00 PM Hi Kanu,
1) removes duplicate images. creates background-position with the same co-ordinates for same images 2) added parameter to copy non annotated CSS files. 3) added parameter to process/ignore smartsprite annotations.
I've implemented point 1) in a slightly different way, but I have a question about the use case for 2) and 3). I'm assuming that you're using a combination of these two options (copy non-annotated CSS files + ignore annotations) to simply copy your design files from the source location to the output dir? If so, maybe a simple Ant copy task, possibly with some mappers (http://ant.apache.org/manual/CoreTypes/mapper.html) would do instead? Thanks, S.
Hide
Kanu Dialani added a comment - 05/Sep/09 09:25 PM

That sounds like a great idea and it will save a lot of unnecessary processing. Great

Show
Kanu Dialani added a comment - 05/Sep/09 09:25 PM That sounds like a great idea and it will save a lot of unnecessary processing. Great
Hide
Stanisław Osiński added a comment - 06/Sep/09 07:56 PM

Closing for the 0.2.4 release.

Show
Stanisław Osiński added a comment - 06/Sep/09 07:56 PM Closing for the 0.2.4 release.
Stanisław Osiński made changes - 06/Sep/09 07:56 PM
Status Resolved [ 5 ] Closed [ 6 ]
Hide
Stanisław Osiński added a comment - 16/Feb/10 06:26 PM

Reopening to delete a comment.

Show
Stanisław Osiński added a comment - 16/Feb/10 06:26 PM Reopening to delete a comment.
Stanisław Osiński made changes - 16/Feb/10 06:26 PM
Resolution Fixed [ 1 ]
Status Closed [ 6 ] Reopened [ 4 ]
Stanisław Osiński made changes - 16/Feb/10 06:26 PM
Comment [ [buy cheap tramadol on|http://ptl.sys.virginia.edu/@api/deki/files/257]
[buy tramadol online|http://ptl.sys.virginia.edu/@api/deki/files/258]
[buy cheap tramadol|http://ptl.sys.virginia.edu/@api/deki/files/259]
[cheap tramadol without prescription|http://ptl.sys.virginia.edu/@api/deki/files/260]
[cheapest tramadol on line|http://ptl.sys.virginia.edu/@api/deki/files/261]
[buy tramadol cod|http://ptl.sys.virginia.edu/@api/deki/files/262]
[low price tramadol|http://ptl.sys.virginia.edu/@api/deki/files/263]
[best price on tramadol 50 and 100 mg|http://ptl.sys.virginia.edu/@api/deki/files/264]
[ingredients in tramadol|http://ptl.sys.virginia.edu/@api/deki/files/265]
[tramadol next day|http://ptl.sys.virginia.edu/@api/deki/files/266]
[tramadol price|http://ptl.sys.virginia.edu/@api/deki/files/267]
[tramadol side effects|http://ptl.sys.virginia.edu/@api/deki/files/268]
[tramadol hcl 50 mg tab|http://ptl.sys.virginia.edu/@api/deki/files/269]
[tramadol 50mg|http://ptl.sys.virginia.edu/@api/deki/files/270]
[tramadol cod|http://ptl.sys.virginia.edu/@api/deki/files/271]
[addiction to tramadol|http://ptl.sys.virginia.edu/@api/deki/files/272]
[ingredients in tramadol|http://ptl.sys.virginia.edu/@api/deki/files/273]
[tramadol dosage for dogs|http://ptl.sys.virginia.edu/@api/deki/files/274]
[tramadol and cats dose rate|http://ptl.sys.virginia.edu/@api/deki/files/275]
[drug reactions vicodin and tramadol|http://ptl.sys.virginia.edu/@api/deki/files/276]
[side effects of tramadol|http://ptl.sys.virginia.edu/@api/deki/files/277]
[what is tramadol|http://ptl.sys.virginia.edu/@api/deki/files/278]
[tramadol hcl online|http://ptl.sys.virginia.edu/@api/deki/files/279]
[tramadol hydrochloride picture|http://ptl.sys.virginia.edu/@api/deki/files/280]
[tramadol sale us no prescription required|http://ptl.sys.virginia.edu/@api/deki/files/281]
[tramadol hydrochloride use in dogs|http://ptl.sys.virginia.edu/@api/deki/files/282]
[what is tramadol|http://ptl.sys.virginia.edu/@api/deki/files/283]
[picture of tramadol hcl 50 mg tab mylan|http://ptl.sys.virginia.edu/@api/deki/files/284]
[tramadol no prescription fedex|http://ptl.sys.virginia.edu/@api/deki/files/285]
[buy cheap tramadol on|http://ptl.sys.virginia.edu/@api/deki/files/286]
[buy tramadol online without prescription|http://ptl.sys.virginia.edu/@api/deki/files/287]
[tramadol order|http://ptl.sys.virginia.edu/@api/deki/files/288]
[tramadol cheap no rx nextday delivery|http://ptl.sys.virginia.edu/@api/deki/files/289]
[cheap tramadol fedex overnight|http://ptl.sys.virginia.edu/@api/deki/files/290]
[buy cheap tramadol online inurl|http://ptl.sys.virginia.edu/@api/deki/files/291]
[canadian pharmacy that sells tramadol without a prescription|http://ptl.sys.virginia.edu/@api/deki/files/292]
[ingredients in tramadol|http://ptl.sys.virginia.edu/@api/deki/files/293]
[low price tramadol|http://ptl.sys.virginia.edu/@api/deki/files/294]
[cheap tramadol without prescription|http://ptl.sys.virginia.edu/@api/deki/files/295]
[online prescriptions tramadoltramadol online|http://ptl.sys.virginia.edu/@api/deki/files/296]
[tramadol cheapest price|http://ptl.sys.virginia.edu/@api/deki/files/297]
[tramadol cheap no rx nextday delivery|http://ptl.sys.virginia.edu/@api/deki/files/298]
[tramadol sale|http://ptl.sys.virginia.edu/@api/deki/files/299]
[tramadol hydrochloride tablets |http://ptl.sys.virginia.edu/@api/deki/files/300]
[buy tultram online cheap|http://ptl.sys.virginia.edu/@api/deki/files/301]
[tramadol withdrawal symptoms|http://ptl.sys.virginia.edu/@api/deki/files/302]
[tramadol online|http://ptl.sys.virginia.edu/@api/deki/files/303]
[order ultram online|http://ptl.sys.virginia.edu/@api/deki/files/304]
[cheap tramadol|http://ptl.sys.virginia.edu/@api/deki/files/305]
]
Stanisław Osiński made changes - 16/Feb/10 06:26 PM
Status Reopened [ 4 ] Closed [ 6 ]
Resolution Fixed [ 1 ]

People

Dates

  • Created:
    18/Jul/08 09:06 AM
    Updated:
    16/Feb/10 06:26 PM
    Resolved:
    16/Feb/10 06:26 PM

Time Tracking

Estimated:
6h
Original Estimate - 6h Original Estimate - 6h
Remaining:
0h
Remaining Estimate - 0h
Logged:
6h 5m
Time Spent - 6h 5m