Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8621811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:54:07+00:00 2026-06-12T06:54:07+00:00

I using the following :convert_options -auto-orient -gravity center -background transparent -extent ’50×50>’ for what

  • 0

I using the following :convert_options

-auto-orient -gravity center -background transparent -extent '50x50>'

for what of my has_attached_file calls, what I WANT to do is rather than using transparent, I’d like to set the background color of the image to the color that lives at 0,0 of the image.

Using

convert rose: -format "%[pixel:u.p{0,0}]" info:-

I get the output

srgb(48,47,45)

which is great, but I’m unable to use that in place of transparent in the actual call..

Can anyone help with how I can pull this off?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:54:08+00:00Added an answer on June 12, 2026 at 6:54 am

    Wrote a custom interpolator for this.

    module Paperclip
      class BgExtrapolator < Processor
        def initialize(file, options = {}, attachment = nil)
          super
    
          @file             = file
          @instance         = options[:instance]
          @current_format   = File.extname(@file.path)
          @basename         = File.basename(@file.path, @current_format)
        end
    
        def make
          src = @file
          dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
          dst.binmode
    
          begin
            # grab the image
            logo = Magick::Image.read(src.path).first
    
            # determine the color of the upper left most pixel
            bg_color = logo.pixel_color(0,0)
    
            # construct an rgba value to provide to imagemagick
            bg_color_value = "rgba(#{bg_color.red >> 8},#{bg_color.green >> 8},#{bg_color.blue >> 8},#{bg_color.to_hsla[3]})"
    
            parameters = []
            parameters << ":source"
            parameters << "-resize '#{options[:geometry].to_s}' -auto-orient -gravity center -background '#{bg_color_value}' -extent '#{options[:geometry].to_s}'"
            parameters << ":dest"
    
            # clean the command
            parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
    
            # run the command
            success = convert(parameters, :source => File.expand_path(src.path), :dest => File.expand_path(dst.path))
          rescue Cocaine::ExitStatusError => e
            raise Paperclip::Error, "There was an error processing the thumbnail for #{@basename}" if @whiny
          rescue Cocaine::CommandNotFoundError => e
            raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `convert` command. Please install ImageMagick.")
          end
    
          dst
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code to convert an NSString to an NSDate :
Within a for loop, I'm using the following code to convert from one date
I am using the following code fragment in z3 4.0 to convert a formula
I am trying to convert following table data into nested array using PHP. I
I'm using the following library https://github.com/Leonidas-from-XIV/node-xml2js To convert XML to JSON. After conversion console.log
Is is possible to do the following using nginx rewrite: Convert a url from
I am trying to convert a NSString into a double using the following: double
I have the following code to convert the type of the matrix using cv::Mat.convertTo()
I am using TimeStamp class to convert seconds into Day,Hours,Minutes,Seconds. I used following code
I'm trying to convert a CVS repository to Git using cvs2svn and am following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.