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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:00:51+00:00 2026-05-28T06:00:51+00:00

I have a specific sized canvas (let’s say 400×300 pixels) and I have an

  • 0

I have a specific sized canvas (let’s say 400×300 pixels) and I have an image which could be any amount, I want to scale down (paying attention to ratios so it is proper ratio) and fit it inside the canvas, that part I know how to do. But I want to then make the canvas 400×300.

So an image let’s say 300×600. It would be scaled to 150×300 (so it fits inside 400×300) and then centered and the image is “applied” to a white canvas of 400×300. And it would do that for any size image.

I don’t know how to do the last part.

  • 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-28T06:00:52+00:00Added an answer on May 28, 2026 at 6:00 am

    UPDATE: Just noticed the comment on your post that you want to do this with PHP bindings. This answer I supplied only applies to the command line, not PHP. I can’t help you with that. But leaving this answer in case it helps.


    To center a smaller image on a large canvas, use the extent operator with gravity. So, for example, if img.gif is your resized 150×300 image, then this will center the image on a 400×300 white canvas:

    -gravity center -extent 400x300 img.gif
    

    [Note you can also set “-background ” if you want a canvas other than white, but it defaults to white.]

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

Sidebar

Related Questions

I have the script that works with pixels in html5 canvas element. And there
I have a list of URL. Each url has an image of specific size.
Given I have a canvas that contains many shapes, lets say rectangles for now.
As I know, an array needs to have a specific size before compiling time
I have a couple of specific questions about font size: Is pt (I.E. 12pt)
In my rails 3.1 app, I have specific files that are to be loaded
I have a specific requirement to read a resource from jar file and then
I have a specific question about looping variable names in WPF. XAML code looks
I have a specific class C and I would like to overload some math
i have this specific question to do to you, i have a database from

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.