-
Notifications
You must be signed in to change notification settings - Fork 6
options.jpeg
Type: Object
Default value: null
This parameters governs the output type: JPEG (when non-null), or PNG (when null).
If specified, it is passed to a canvas object as parameter when creating a JPEG stream.
See Canvas#jpegStream() and Canvas#syncJPEGStream()
for details. If null, a PNG stream is created.
The most frequently used parameters to generate JPEG are quality, which is a number
from 0 to 100 (default: 75), and progressive, which is a boolean value (default: false).
It is important to know that this setting can affect a destination file name. If dest
has an extension, it is used as is, but if there is no extension, '.png' or '.jpg'
will be added depending on options.jpeg value.
Default configuration:
grunt.initConfig({
tight_sprite: {
// describe my sprite
icons: {
cwd: "images/icons",
src: ["**/*.png"],
dest: "images/icons.png"
}
}
})The spite will have type PNG, and it will be placed in images/icons.png.
JPEG of quality 85:
grunt.initConfig({
tight_sprite: {
// describe my sprite
icons: {
options: {
jpeg: {
quality: 85
}
},
cwd: "images/icons",
src: ["**/*.png"],
dest: "images/icons.jpeg"
}
}
})The spite will have type JPEG, and it will be placed in images/icons.jpeg.
Regular PNG:
grunt.initConfig({
tight_sprite: {
// describe my sprite
icons: {
options: {
jpeg: null
},
cwd: "images/icons",
src: ["**/*.png"],
dest: "images/icons.xyz"
}
}
})The spite will have type PNG, and it will be placed in images/icons.xyz.
JPEG of quality 90:
grunt.initConfig({
tight_sprite: {
// describe my sprite
icons: {
options: {
jpeg: {
quality: 90
}
},
cwd: "images/icons",
src: ["**/*.png"],
dest: "images/icons.xyz"
}
}
})The spite will have type JPEG, and it will be placed in images/icons.xyz.
Regular PNG with an automatic file extension:
grunt.initConfig({
tight_sprite: {
// describe my sprite
icons: {
cwd: "images/icons",
src: ["**/*.png"],
dest: "images/icons"
}
}
})The spite will have type PNG, and it will be placed in images/icons.png.
Progressive JPEG with an automatic file extension:
grunt.initConfig({
tight_sprite: {
// describe my sprite
icons: {
options: {
jpeg: {
progressive: true
}
},
cwd: "images/icons",
src: ["**/*.png"],
dest: "images/icons"
}
}
})The spite will have type JPEG, and it will be placed in images/icons.jpg.