2012-11-20 4 views

답변

12

을 그냥 이유 안드레이의 코드하셨습니까을 찾기 위해 노력하고 세 시간 동안 때문에 나는, MiniMagick이 일부 변경했다 생각 나를 위해 일하지 마라.

ActiveRecord::RecordInvalid (Validation failed: 
Image Failed to manipulate with MiniMagick, maybe it is not an image? 
Original Error: Command 
("mogrify -scene /var/folders/0o/0oqNck+++TI/-Tmp-/mini_magick2022-499-15zc.gif") 
failed: {:status_code=>1, :output=>"mogrify: invalid argument for option 
`/var/folders/0o/0oqNck+++TI/-Tmp-/mini_magick2022-499-15zc.gif': -scene 
@ error/mogrify.c/MogrifyImageCommand/5558.\n"}) 

마지막으로 내가 MiniMagick :: 이미지는 방법 collapse! (여기 : http://www.ruby-doc.org/gems/docs/j/jf--mini_magick-3.1/MiniMagick/Image.html#method-i-collapse-21)가 발견 : 문제 해결 : 그것은했다

process :remove_animation 

def remove_animation 
    manipulate! do |img| 
    if img.mime_type.match /gif/ 
     img.collapse! 
    end 
    img 
    end 
end 
+0

나는 그것을 시도하지는 않았지만 이상적이라고 생각합니다. 게시 해 주셔서 감사합니다. – alistairholt

+0

'manipulate! (& : collapse!) if content_type =='image/gif ''라고하는 방법으로 다시 쓸 수 있습니다. –

3

그것은 작품 :

def only_first_frame 
    manipulate! do |img| 
     if img.mime_type.match /gif/ 
     if img.scene == 0 
      img = img.cur_image #Magick::ImageList.new(img.base_filename)[0] 
      else 
      img = nil # avoid concat all frames 
     end 
     end 
     img 
    end 
    end 

그럼 당신은 호출해야합니다 :

process :only_first_frame 
+0

사과 있음을

나는 다음과 같은 오류가 발생했습니다 당신의 대답을 받아들이 길 바랍니다. – alistairholt

관련 문제