Closed SnisarOnline closed 7 years ago
This is a duplicate of #64. The issue in this configuration is retinaSrcFilter
is an array when it should be a string. The following config should work:
gulp.task('t_sprite', function () {
var spriteData = gulp.src(imgDir+'*.png')
.pipe(debug({title:"png : "}))
.pipe(spritesmith({
retinaSrcFilter: imgDir+'*@2x.png',
imgName: 'sprite.png',
retinaImgName: 'sprite@2x.png',
cssName: 'sprite.styl'
}));
return spriteData.pipe(gulp.dest(Sprite_Styl));
});
here is my test file, please look at the files https://github.com/SnisarOnline/examples
There are no 2x.png
in that repository.
If you are trying to only generate 1x spritesheets (i.e. don't care about retina), then if you remove retinaSrcFilter
and retinaImgName
, then it will work fine.
Otherwise, you'll need to provide 2x sprites to generate 2x spritesheets as we can't upscale 1x images without losing quality (and defeating the purpose of a 2x spritesheet)
sorry for bad English can I get a working example. I tried a lot more options than what is indicated in the files and not one worked
Sure thing, I will rephrase my explanation as well. Retina spritesheets, also known as 2x spritesheets, are for showing better image quality on devices that support it. For example, a Macbook Pro and iPhone have retina displays which can show better image quality.
We support generating retina spritesheets in gulp.spritesmith
via parameters like retinaSrcFilter
and retinaImgName
. Currently, the example you provided has these parameters set so it is attempting to generate retina spritesheets. However, it's not finding any retina images to generate the retina spritesheet with.
As a result, I'm assuming you are accidentally using these parameters and only want to generate a normal spritesheet at this time. To correct our gulpfile.js
, we should have the following configuration:
gulp.task('t_sprite', function () {
var spriteData = gulp.src(imgDir+'*.png')
.pipe(debug({title:"png : "}))
.pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.styl'
}));
return spriteData.pipe(gulp.dest(Sprite_Styl));
});
This configuration doesn't include the retina parameters retinaSrcFilter
and retinaImgName
. As a result, it will not attempt to generate a retina spritesheet.
so, the software does not Create "retina image". the software USE the ALREADY Created "retina images". and create "sprites" I right understand ?
That is partially correct. The concept is correct but the terminology is incorrect. The software uses already created "sprites" (small images) and then creates "spritesheets" (all images in one image).
To create retina images, you must generate those from your source (e.g. Photoshop, Illustrator). If you would like to automate creating normal images from retina images, then this can be done via other plugins such as:
thanks for the clear explanation. And I am sorry for the trouble
I'm trying to create a retina sprite with this gulp task:
When I run the task, it gives me this error: