Tag: paperclip

带有ImageMagick和Rails的像素RGB

我目前正在使用PaperClip和ImageMagick上传图像。 我想得到图像的平均颜色,所以我这样做(使用before_create挂钩): def get_average_color img = Magick::Image.read(self.url).first pix = img.scale(1, 1) averageColor = pix.pixel_color(0,0) end 这有效,但当我尝试打印像素颜色时,我得到它们像这样: red=36722, green=44474, blue=40920, opacity=0 如何将这些RGB值转换为常规(0-255)RGB值。 我只是修改它们吗? 提前致谢。

回形针video上传

我正在尝试在我的post中启用video上传function。 无法让它显示video。 video上传,我可以确认,虽然我设法右键点击video区域并下载它。 问题是如何正确查看它。 移民: class AddAttachmentVideoToPosts < ActiveRecord::Migration def self.up change_table :posts do |t| t.attachment :video end end def self.down drop_attached_file :posts, :video end end def change create_table :videos do |t| t.string :video_file_name t.string :video_content_type t.integer :video_file_size t.datetime :video_updated_at t.timestamps end end 发布模型 class Post ‘created_at desc’ attr_accessible :content, :title, :photo, :photo_delete, :video, :video_delete, […]

回形针使用Heroku设置Amazon S3

has_attached_file :image, :storage => :s3, :s3_credentials => “#{RAILS_ROOT}/config/s3.yml”, :path => “/:style/:filename” 我不确定是什么:path => “/:style/:filename”是。 我还想为这个附加图像添加样式,那是什么:路径是什么? 我想要的样式是:styles => { :medium => “275×275>”, :thumb => “175×155>” } 基本上这里发生的是我正在设置heroku并且我不得不使用S3,这似乎很简单,只是不习惯这个附件约定的东西。 此外,我刚刚注册了一个S3帐户……但是heroku正在宣传它的免费或其他东西。 这有什么用?

Heroku:使用回形针运行imagemagick

我在我的mac os x计算机上安装了image magick,现在我想将它部署到heroku。 我在heroku上安装了paperclip插件,但上传图片时出现此错误: Paperclip::CommandNotFoundError 之前我在计算机上没有imagemagick instaledl时出现此错误,但现在我想部署它, 如何让图像magick在heroku上工作?

Ruby on Rails,Paperclip,亚马逊AWS S3和Heroku

我尝试了两天,让我的所有网站都通过Heroku和亚马逊AWS S3在互联网上工作(存储我的图像),但……我无法做到! 为了简化,我想使用带有回形针的Heroku和Amazon AWS S3来上传图片并进行显示。 我遵循了很多教程但是,这个总结了我所做的一切: https : //devcenter.heroku.com/articles/paperclip-s3 上传系统适用于本地的基本存储,但如果我按照教程并将此代码放在我的环境中,我就会出错 config.paperclip_defaults = { :storage => :s3, :s3_credentials => { :bucket => ENV[‘S3_BUCKET_NAME’], :access_key_id => ENV[‘AWS_ACCESS_KEY_ID’], :secret_access_key => ENV[‘AWS_SECRET_ACCESS_KEY’] } } 首先是我的代码,然后我会写出我在本地的错误,以及我尝试在Internet上测试时的错误(Heroku打开)。 我的代码: develpment.rb: Blabla::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application’s code is […]

使用Sinatra上传文件

我正在尝试使用Sinatra上传文件。 我在这里有代码,但是我收到错误“方法file_hash不存在”(请参阅​​/lib/mvc/helpers/helpers.rb)。 这里发生了什么? 我缺少一些依赖吗?