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 6754069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:14:12+00:00 2026-05-26T13:14:12+00:00

When the user updates an image, I would like to crop it to different

  • 0

When the user updates an image, I would like to crop it to different sizes to suit different specifications in the application like a bigger size image for profile page, a smaller image for comments etc. Is there any gem available for this in rails?

  • 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-05-26T13:14:12+00:00Added an answer on May 26, 2026 at 1:14 pm

    I would advise you to use the Paperclip gem for this. With it, you can define several sizes for your image. You do need to have ImageMagick installed for this to work. Your ruby model would have a line like this:

    has_attached_file :image, :styles => { :small => "150x150>", :medium => "400x400#", :large => "640x640" }
    

    The default behavior is to resize to the smallest dimension and keep the aspect ratio. You can use some options to change this:

    1. trailing #, thumbnail will be centrally cropped, ensuring the requested dimensions.
    2. trailing >, thumbnail will only be modified if it is currently larger requested dimensions.

    In your code you can then request the image using image_tag @model.image.url(:small) in your view.

    Ryan bates has an excellent railscast on this if you want more information. Paperclip also has an extensive wiki on GitHub.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to access profiles table from my Profile model which belongs_to :user
I would like to share some text and an image from my web application
I want to implement a Facebook updates(user action and notifications) on my web application
I am developing an application which requires real-time updates to the end user. However,
I would like to make frequently changes for the contact's image on the iPhone.
My problem is: I would like to allow my user to pin single element
Is there a way to get an update by email when a user updates
I'm using Twitter's OAuth API to updates a user's twitter account (twitter status update)
I have a Win32 C++ program that validates user input and updates the UI
I'm trying to make a progress bar that updates the user on the progress

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.