paperclip

Access image from different view in a view with paperclip gem ruby on rails

别说谁变了你拦得住时间么 提交于 2019-12-02 16:51:51
问题 I'm new in Ruby on Rails and learning it. I want to access a table with images stored by paperclip gem in another view, for example in my application, I have the causes controller, I can access the image in the view causes stored in the table by this code: =image_tag @cause.images.first.image.url(:thumb), But i have access too, the images stored in the table from a profile controller. So, how do i access the object of view Profiles in the view Causes? I try in the causes controller: ->

Saving the images Dimensions (width and height) in Paperclip?

我与影子孤独终老i 提交于 2019-12-02 16:45:32
Any Paperclip wizards out there know if you can when using Paperclip to save an image, also save the image dimensions (width and height) in 2 extra fields? How do you get such data during the Paperclip upload process? Nikita Rybak Just for the sake of completeness, even though previous answers already show good enough suggestions. You can utilize Paperclip event handlers instead of Rails callbacks. In this case, size will be recalculated only when image changes. (If you're using S3 for storage, this can save quite some time) has_attached_file :image, :styles => ... after_post_process :save

Rails 4 and paperclip - Stop the :original style file upload to copy it from an S3 remote directory

自闭症网瘾萝莉.ら 提交于 2019-12-02 16:40:18
问题 I use Paperclip 4.0.2 and in my app to upload pictures. So my Document model has an attached_file called attachment The attachment has few styles, say :medium, :thumb, :facebook In my model, I stop the styles processing, and I extracted it inside a background job. class Document < ActiveRecord::Base # stop paperclip styles generation before_post_process false end But the :original style file is still uploaded! I would like to know if it's possible to stop this behavior and copy the file

Paperclip Resize to fit a rectangular box

霸气de小男生 提交于 2019-12-02 16:21:05
I have a rectangular image for example 30x800 pixels How I can scale it with paperclip to preserve the aspect ratio to a 100x100 pixel image with borders filling the empty area ? an example : http://www.imagemagick.org/Usage/thumbnails/pad_extent.gif has_attached_file :image, :styles => { :thumb => "100x100>" }, :convert_options => {:thumb => "-gravity center -extent 100x100"} Or with not white background has_attached_file :image, :styles => { :thumb => "100x100>" }, :convert_options => {:thumb => "-background red -gravity center -extent 100x100"} 来源: https://stackoverflow.com/questions

Saving files using Paperclip without upload

穿精又带淫゛_ 提交于 2019-12-02 15:48:11
I had a quick question. Is it possible to save a file without actually uploading it through a form? For example, let's say I'm looking at attachments from emails, and I want to save them using a paperclip. How do I do this? Do I manually have to call a save_file(or something similar) somewhere? Any help would be much appreciated! I have a rake task that loads images (client logos) from a directory directly onto parperclip. You can probably adapt it to your needs. This is my simplified Client model: class Client < ActiveRecord::Base LOGO_STYLES = { :original => ['1024x768>', :jpg], :medium => [

Resize existing images to new style in paperclip & RMagick

馋奶兔 提交于 2019-12-02 15:39:33
I've been using paperclip to upload and auto-resize photos in my Rails app, and I love it. Only problem is about every other month my crazy manager decides he wants a new size to display the photos in. So I add a new style in my Photo model and all is good for new photos, but the pre-existing photos are now a problem. Now that I'm starting to have more than a few photos to deal with I need a programmatic way to resize existing photos. Perhaps there is some paperclip trick for such a thing? I'd really rather not have to figure out RMagick and write a script myself if I don't have to. You want

Paperclip: How to store a picture in a Rails console?

不羁岁月 提交于 2019-12-02 15:31:14
I tried storing a local image in a rails console. Because I have many pictures in my local storage (I use crawler to download tons of pictures), I want to store them into a database, with the benefit of paperclip to do some image job, like thumbnail etc. If I use a webpage to save new pictures to database one by one, it will cost a lot of time. So I want to find a way in rails console (some code) that can batch save-picture-into-database. To further clarify @andrea's answer: YourPaperclippedModelHere.new(:your_paperclip_field => File.new(path, "r")) So if your model is called Image and your

ImageMagick on Google Cloud

送分小仙女□ 提交于 2019-12-02 12:59:55
I use ImageMagick on the Google Cloud Platform. I use rails and Google's App Engine Flexible Environment. So the problem is I want to upload an Image to process in more sizes. I use paperclip. The error is: Could not run the identify command. Please install ImageMagick. So my question is how I can solve this issue? Uploading a Image without processing works 100%. But the issue is the processing I think. So paperclip needs ImageMagick to process the images. The problem is I use App Engine Flexible Environment so I am not sure how to install it. I already tried it with apt-get install

paperclip gem validation error - 'filename' is not recognized by the 'identify' command

半世苍凉 提交于 2019-12-02 10:33:58
I'm trying to get the paperclip gem to upload images on my production server (ubuntu 12.0.4, apache2, phusion passenger and rvm) and for each attachment I get three lots of this validation error: Img one /tmp/villa-0520121006-4333-hdo9wv.jpeg is not recognized by the 'identify' command. ImageMagick is installed properly, as is the libmagickwand-dev package, Rmagick and paperclip. And I've set the correct command_path to where identify and convert are located in my production.rb config file. here is my model if it helps: class Property < ActiveRecord::Base attr_accessible :img_one, :img_two,

Access image from different view in a view with paperclip gem ruby on rails

淺唱寂寞╮ 提交于 2019-12-02 09:31:36
I'm new in Ruby on Rails and learning it. I want to access a table with images stored by paperclip gem in another view, for example in my application, I have the causes controller, I can access the image in the view causes stored in the table by this code: =image_tag @cause.images.first.image.url(:thumb), But i have access too, the images stored in the table from a profile controller. So, how do i access the object of view Profiles in the view Causes? I try in the causes controller: -> @profile = Profile.all -> =image_tag @profile.images.first.image.url(:thumb), but not work, so friends, how