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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:19:37+00:00 2026-05-21T15:19:37+00:00

i need to concatenate images in php (two or more), both vertically and horizontally.

  • 0

i need to concatenate images in php (two or more), both vertically and horizontally. What’s the fastest way to do that?

obs: i don’t want to use non-native libraries

another doubts. will the resulting image have the sum of the images sizes or could it be significantly bigger?

thanks (:

  • 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-21T15:19:38+00:00Added an answer on May 21, 2026 at 3:19 pm
    $newWidth = $w1 + $w2;
    $newHeight = $h1 + $h2;
    $newImage = imagecreatetruecolor($newWidth, $newHeight);
    
    imagecopyresampled($newImage, $image1, 0, 0, 0, 0, $w1, $h1, $w1, $h1);
    imagecopyresampled($newImage, $image2, $w1, 0, 0, 0, $w2, $h2, $w2, $h2);
    

    Now i did just code this in stack overflows editor and it is untested, but that should use all native libraries and probably be the fastest. Just copies and resamples the image1 into the first half (width wise) and then copies the second image into the second half (width wise), if you wanted to do it by stacking on height, it would just be changing where the dest_h is. Here is some info… http://php.net/manual/en/function.imagecopyresampled.php

    oh BTW, that was for saving an image. That is what i am assuming your doing. Else the answer about stacking 2 images next to eachother with tags would be the fastest.

    As far as the resulting image, remember. If they are laid horizontally, then the width would be $w1 + $w2 and the height would be math.max($h1, $h2) and opposite if the images are stacked vertically

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

Sidebar

Related Questions

I need to concatenate two string and display with single text view. That string
It's very pointless and troublesome that everytime that you need to concatenate two strings
I have table that has two columns and I need to concatenate these two
I need to allow full-text searching on two fields that are concatenated together. In
I've got 50 to 60 files in a directory that I need to concatenate
I need to concatenate two string variables and place the result back in the
I need to concatenate two const chars like these: const char *one = Hello
I need to concatenate two files. I use Ant's exec for this purpose, but
I need to concatenate a file id before insert, thus want to lock a
I need to concatenate two string in another one without their intersection (in terms

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.