// Path: src/main/java/org/carrot2/labs/smartsprites/SpriteImageDirective.java
// public enum SpriteUidType
// {
//     /**
//      * No UID extension.
//      */
//     NONE,
// 
//     /**
//      * Append current timestamp as long.
//      */
//     DATE,
// 
//     /**
//      * Append MD5 of the sprites file.
//      */
//     MD5;
// 
//     private String value;
// 
//     public final Pattern pattern;
// 
//     private SpriteUidType()
//     {
//         this.value = name().toLowerCase();
//         this.pattern = Pattern.compile("${" + value + "}", Pattern.LITERAL);
//     }
// 
//     @Override
//     public String toString()
//     {
//         return value;
//     }
// 
//     public static String valuesAsString()
//     {
//         final String list = Lists.newArrayList(values()).toString();
//         return list.substring(1, list.length() - 1);
//     }
// }


import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.carrot2.labs.smartsprites.SpriteImageDirective.SpriteUidType;
     */
    public float scaleRatio;

    private static final Pattern SPRITE_VARIABLE = Pattern.compile("${sprite}",
        Pattern.LITERAL);

    public SpriteImage(BufferedImage sprite, SpriteImageOccurrence spriteImageOccurrence,
        Map<SpriteReferenceOccurrence, SpriteReferenceReplacement> spriteReplacements,
        int width, int height, float scale)
    {
        this.sprite = sprite;
        this.spriteReferenceReplacements = spriteReplacements;
        this.spriteImageOccurrence = spriteImageOccurrence;
        this.spriteWidth = width;
        this.spriteHeight = height;
        this.scaleRatio = scale;

        for (SpriteReferenceReplacement replacement : spriteReplacements.values())
        {
            replacement.spriteImage = this;
        }
    }

    String resolveImagePath(byte [] image, String timestamp, boolean reducedForIe6) throws IOException
    {
        String imagePath = spriteImageOccurrence.spriteImageDirective.imagePath;

        // Backwards compatibility: if there are no place holders in the path
        // and the UID type is defined, append the UID as a query string just like
        // the previous versions did. To be removed in 0.4.0.
// Path: src/main/java/org/carrot2/labs/smartsprites/SpriteImageDirective.java
// public enum SpriteUidType
// {
//     /**
//      * No UID extension.
//      */
//     NONE,
// 
//     /**
//      * Append current timestamp as long.
//      */
//     DATE,
// 
//     /**
//      * Append MD5 of the sprites file.
//      */
//     MD5;
// 
//     private String value;
// 
//     public final Pattern pattern;
// 
//     private SpriteUidType()
//     {
//         this.value = name().toLowerCase();
//         this.pattern = Pattern.compile("${" + value + "}", Pattern.LITERAL);
//     }
// 
//     @Override
//     public String toString()
//     {
//         return value;
//     }
// 
//     public static String valuesAsString()
//     {
//         final String list = Lists.newArrayList(values()).toString();
//         return list.substring(1, list.length() - 1);
//     }
// }


// Path: src/main/java/org/carrot2/labs/smartsprites/SpriteImage.java
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.carrot2.labs.smartsprites.SpriteImageDirective.SpriteUidType;

     */
    public float scaleRatio;

    private static final Pattern SPRITE_VARIABLE = Pattern.compile("${sprite}",
        Pattern.LITERAL);

    public SpriteImage(BufferedImage sprite, SpriteImageOccurrence spriteImageOccurrence,
        Map<SpriteReferenceOccurrence, SpriteReferenceReplacement> spriteReplacements,
        int width, int height, float scale)
    {
        this.sprite = sprite;
        this.spriteReferenceReplacements = spriteReplacements;
        this.spriteImageOccurrence = spriteImageOccurrence;
        this.spriteWidth = width;
        this.spriteHeight = height;
        this.scaleRatio = scale;

        for (SpriteReferenceReplacement replacement : spriteReplacements.values())
        {
            replacement.spriteImage = this;
        }
    }

    String resolveImagePath(byte [] image, String timestamp, boolean reducedForIe6) throws IOException
    {
        String imagePath = spriteImageOccurrence.spriteImageDirective.imagePath;

        // Backwards compatibility: if there are no place holders in the path
        // and the UID type is defined, append the UID as a query string just like
        // the previous versions did. To be removed in 0.4.0.
        if (spriteImageOccurrence.spriteImageDirective.uidType != SpriteUidType.NONE