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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:48:50+00:00 2026-06-10T20:48:50+00:00

I have users uploading always-square images (of variable dimensions, but always square), and I

  • 0

I have users uploading always-square images (of variable dimensions, but always square), and I would like to overlay my own image (also, as it was, a square and of fixed dimensions) in the middle of the square image, regardless of the size.

I know I could use GD and play with the dimensions, but is there an way to auto-center it with fewer lines of code?

I don’t need anything fancy, just an image put into the center of another image.

  • 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-10T20:48:52+00:00Added an answer on June 10, 2026 at 8:48 pm

    I’m confused whether you’re asking how to do this in GD, or an alternative to GD. If you wanted to use the GD library, you could use the imagecopy() function and attempt something like the following:

    <?php
    $uploaded = imagecreatefrompng("../image.png"); //user uploaded
    $watermark = imagecreatefrompng("../logo.png"); //watermark or logo
    
    $x = imagesx($uploaded) / 2 - imagesx($watermark) / 2;
    $y = imagesy($uploaded) / 2 - imagesy($watermark) / 2;
    
    imagecopy($uploaded, $watermark, $x, $y, 0, 0, imagesx($watermark), imagesy($watermark));
    
    header("Content-type: image/png");
    imagepng($uploaded);
    
    imagedestroy($uploaded);
    imagedestroy($watermark);
    

    Otherwise, could you be a bit more specific on what you want? I mean, you could do it with different libraries like ImageMagick, but there aren’t necessarily better ways to do it.

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

Sidebar

Related Questions

I'ld like to present always the latest website content to the user but also
I have been having lot of problems with users uploading images on my website.
I would like to prevent users from uploading files with certain extensions. First thing
I have an image upload for a slideshow, and the users are continuously uploading
I have users that have several objects and can upload images for those objects.
We have a few 100 users logging in via FTP and uploading files. Our
I have an user registration form and uploading image with other form elements is
I have a script that is uploading images to my site, it works locally
im designing a system where i will have multiple users uploading large amount of
I have a problem with file uploading on Heroku server. (Also a hint about

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.