2013-11-13 2 views
0

Если я скажу, что файл вызова 'mask.png', чем этот код работает:Ruby: не удалось открыть файл ` "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

Что произойдет, если вы поместите изображение в той же папке, что и файл SCSS? –

+0

... такая же ошибка. Проблема не в пути. Он находит изображение, но он не хочет его открывать ... –

+1

попробуйте просто пропустить mask.png с тиками ... похоже, что это может быть обертка ваших котировок в кавычках – beauXjames

ответ

0

меня добавить это imageColor.rb:

source_file = [sourceFile,".png"].join("") 
target_file = [targetFile,".png"].join("")   
source_color = [sourceColor].join("")   
target_color = [targetColor].join("") 
Смежные вопросы