2015-01-09 5 views
1

캡션 및/또는 레이블을 사용하여 이미지에 여러 줄 문자를 쓰려고하는데 이미지에 아무 것도 쓰지 않습니다. 내가 ImageMagick이 마술 캡션/레이블의 포인트 사이즈를 확장 할 수 있음을 읽을 수 있기 때문에캡션/레이블 방법이 작동하지 않습니다.

def self.post_open_ended_response 
    image = MiniMagick::Image.open("public/text_response_bg.png") 
    image.combine_options do |i| 
    i.size "460x" 
    i.gravity 'center' 
    i.fill 'white' 
    i.pointsize '40' 
    i.caption 'blahblahblah' 
    # i.label "blahblah fsdfsd fsd fsd fds fsd fds fds" 
    # i.composite "public/output.jpg" 
end 
image.write "public/output.jpg" 
end 

내가 텍스트 대신 캡션/라벨을 사용하려는 이유입니다. 내 텍스트 길이가 다를 수 있으므로 하드 코딩을 원하지 않습니다.

+0

그동안이 문제를 해결할 수 있었습니까? 같은 문제에 직면 해있다. –

답변

0

앞으로 문제가 될 수있는 모든 사람들에게 - 최신 젬 (순간 4.2.0)으로 업데이트하십시오. 나는 4.0.4에이고 문제가 있었다 :

https://github.com/minimagick/minimagick/issues/191

업데이트 - 간단하게 사용하는 일반적인 주석의를 - 그것은 작동합니다. 텍스트 조작이 필요한 경우 TextHelpers를 사용하여 텍스트 조작을 할 수 있습니다. 여러 줄 주석의 예제로 다음을 수행했습니다.

def create_og_image 
    message = word_wrap('This is a test string. ' + @blog.title, line_width: 30).upcase 

    image = MiniMagick::Image.open(@blog.image.path(:open_graph)) 
    image.combine_options do |c| 
    #c.label message 
    c.gravity 'NorthWest' 
    c.fill 'white' 
    c.stroke 'white' 
    c.strokewidth '0' 
    c.pointsize '70' 
    c.interline_spacing '10' 
    c.font "AvantGarde-Book" 
    #c.size "500x300 label:'#{message}'" 
    #c.label message 
    c.annotate '+500+318', message 

    end 

    image.write "/xxx/xxx/xxx/public/test_image/test_output.jpg" 
end