0

what I'd like to do is very simple. I have a code which uses a imgkit library to load some webpage image and then stores it. It looks like that:

kit = IMGKit.new(site, :quality => 5, :width => 1024)
img = kit.to_img(:png)
file = kit.to_file("#{Rails.root}/public/images/#{s2}.png")

I need to know the image height after loading in order to stretch canvas element behind it. Is there a way I can get the height ? Or if not, how could I achieve this without knowing the image height before loading, javascript ?

4

2 回答 2

0

好的,我已经想通了。Mini_magick gem 是一个很好的方法来做到这一点。

于 2016-04-09T09:05:41.967 回答
0

相关问题

跟随工作吗?

kit = IMGKit.new(site, :quality => 5, :width => 1024)
img = kit.to_img(:png)
file = kit.to_file("#{Rails.root}/public/images/#{s2}.png")  

var img2 = new Image();       
img2.onload = function(){
  var height = img2.height;

  //do all remaining processing here

};
img2.src = file;
于 2016-04-08T12:03:03.050 回答