Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did not test this, but you should be able to use the "convert_options" parameter, like this:</p> <pre><code>:convert_options =&gt; { :all =&gt; ‘-colorspace Gray’ } </code></pre> <p>Have a look at <a href="https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/thumbnail.rb" rel="noreferrer">https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/thumbnail.rb</a></p> <p>I personnaly use my own processor.</p> <p>In Model:</p> <pre><code> has_attached_file :logo, :url =&gt; PaperclipAssetsController.config_url, :path =&gt; PaperclipAssetsController.config_path, :styles =&gt; { :grayscale =&gt; { :processors =&gt; [:grayscale] } } </code></pre> <p>In lib:</p> <pre><code>module Paperclip # Handles grayscale conversion of images that are uploaded. class Grayscale &lt; Processor def initialize file, options = {}, attachment = nil super @format = File.extname(@file.path) @basename = File.basename(@file.path, @format) end def make src = @file dst = Tempfile.new([@basename, @format]) dst.binmode begin parameters = [] parameters &lt;&lt; ":source" parameters &lt;&lt; "-colorspace Gray" parameters &lt;&lt; ":dest" parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ") success = Paperclip.run("convert", parameters, :source =&gt; "#{File.expand_path(src.path)}[0]", :dest =&gt; File.expand_path(dst.path)) rescue PaperclipCommandLineError =&gt; e raise PaperclipError, "There was an error during the grayscale conversion for #{@basename}" if @whiny end dst end end end </code></pre> <p>This might not be 100% necessary for a simple grayscale conversion, but it works!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload