如果我说文件调用'mask.png'比这段代码有效:
#imageColor.rb
require 'RMagick'
include Magick
module Sass::Script::Functions
def imagetest(sourceFile, targetFile, sourceColor, targetColor)
sources = Image.read('mask.png')
target = sources[0].opaque('black', 'blue')
target.write('test.png')
Sass::Script::String.new("#00ff00")
end
end
#_imageColor.scss
@mixin image-color($source, $target, $sourceColor, $targetColor)
{
color: imagetest($source, $target, $sourceColor, $targetColor);
}
#ie.scss
@import "theme/default/ie/ie";
@import "imageColor";
body {
@include image-color('mask.png', 'test.png', '#000000', '#ff0000');
}
如果我在方法image-color(在ie.scss中)说文件调用'mask.png'而不是这个代码:
#imageColor.rb
require 'RMagick'
include Magick
module Sass::Script::Functions
def imagetest(sourceFile, targetFile, sourceColor, targetColor)
sources = Image.read(sourceFile)
target = sources[0].opaque(sourceColor, targetColor)
target.write(targetFile)
Sass::Script::String.new("#00ff00")
end
end
错误:
unable to open image `"mask.png"': No such file or directory
你知道为什么吗?
答案 0 :(得分:0)
我已将此添加到imageColor.rb:
source_file = [sourceFile,".png"].join("")
target_file = [targetFile,".png"].join("")
source_color = [sourceColor].join("")
target_color = [targetColor].join("")