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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:10:28+00:00 2026-06-13T12:10:28+00:00

My script glues several images into one image but result image have single color

  • 0

My script glues several images into one image but result image have single color dominated on first image from glue images set:

enter image description here

But input 4 images are in different colors (yellow, green, blue, red). Only first image from set is looks correct.

$images = array();

foreach ($fileNames as $fileName) {
    $image = imagecreatefrompng($path . $fileName);
    if ($image) {
        $images[] = $image;
    }
}

// ...

$img = imagecreate($w, $h);

$x = 0;
foreach ($images as $image) {
    $width = imagesx($image);
    $height = imagesy($image);

    imagecopy($img, $image, $x, 0, 0, 0, $width, $height);
    $x += $width;
}

Another one example (if first image from glue set is blue and other in differ colors):

enter image description here

  • 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-13T12:10:29+00:00Added an answer on June 13, 2026 at 12:10 pm

    You are probably mixing paletted images, whereby the palette will be taken from the first destination image.

    Convert them to TrueColor by creating a True Color image of suitable size, then imageCopy’ing all images into that one.

    Afterwards, you can try reducing the destination image to palette again, even if this may yield slightly “off” colours.

    $img = imageCreateTrueColor($w, $h);
    // Add transparency management if needed
    
    $x = 0;
    foreach ($images as $image) {
        $width  = imagesx($image);
        $height = imagesy($image);    
        imagecopy($img, $image, $x, 0, 0, 0, $width, $height);
        $x += $width;
    }
    // Reduce image to non-dithered, 256-color paletted if needed
    // imageTrueColorToPalette($img, False, 256);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

aspx script: <script type=text/javascript> $(document).ready(function() { $(.div_soru).hide(); $(.div_soru).first().show(); $(.onceki).click(function() { if ($(this).closest(.div_soru).prev(.div_soru).html() != null)
My script works seemed to be working perfectly well, but Eclipse 3.7.2 was telling
The script below works fine if 3 and 3.2 are not links but i
This script has been working on 10.7 and older, but in 10.8, it seems
I am using zeroClipboard but I don't manage to have it working. Here is
Is this possible ? This is with a model CUploadedFile::getInstance($model,'newsimage'); $model->image->saveAs(image\path) but I don't
script/console output: >> User.find(:first, :select => '`email`, `pass`, `login`, `id`') => #<User pass: e10adc3949ba59abbe56e057f20f883e,
My script requires connections to several databases. Some parts only need to connect to
Script <script language=javascript type=text/javascript> function FinalFunction() { //Your First Script return confirm('Are you sure
The script works perfect in FF and IE, but not in Chrome. Could someone

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.