【问题标题】:Check image if portrait or landscape?检查图像是纵向还是横向?
【发布时间】:2014-06-14 10:41:11
【问题描述】:

我有一个裁剪图像系统,我只希望将纵向图像发送到该系统。 问题是我不知道如何在将图像发送到一个或另一个地方之前验证它们是肖像还是风景。

我想到了 Mini Magick,也许是这样的? (不会工作)

照片模型

  def validate_image_size
    image = MiniMagick::Image.open(photo.path)
     if image[:height] > image[:width]
      #send the image to this place
    end
  end

【问题讨论】:

    标签: ruby-on-rails image-processing minimagick


    【解决方案1】:

    好的,验证器现在正在工作。

      def validate_image_size
        image = MiniMagick::Image.open(photo.path)
         if image[:height] > image[:width]
          #send the image to this place
        end
      end
    

    【讨论】:

    • 验证工作正常,但我收到一个奇怪的错误:Errno::ENOENT in PhotosController#create No such file or directory -
    猜你喜欢
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多