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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:05:02+00:00 2026-05-23T16:05:02+00:00

Here is what I want to do. I have a class that I have

  • 0

Here is what I want to do. I have a class that I have created but I only want the certain parts of the class to show IF certain values are set in the database. What the class does is that it colors the base image and then places another image on top. Sometimes though there are multiple layers set in the database so the class has to adjust to accommodate.

DOES anyone know how or make any suggestions on how I can do this??

SO for example this class allow a base image to be colored and another to be scaled and placed on top:

public function layers2 ($target, $art, $newcopy, $red, $blue, $green) {

    $artLayer = imagecreatefrompng($art); // Art Layer  
    $base = imagecreatefrompng($target); // Base Product
    $base_location = "base";

    $img = imagecreatefrompng($base);

    $width3 = imagesx( $artLayer ); // artLayer
    $height3 = imagesy( $artLayer ); // artLayer

    //COLOR THE IMAGE
    imagefilter($base, IMG_FILTER_COLORIZE, $red, $green, $blue, 1); //the product

    imagecopyresampled($base,$artLayer,350, 150, 0, 0, 300, 300, imagesx( $artLayer ), imagesy( $artLayer ));       // rotate image 

    // save the alpha
    imagesavealpha($base,true);
    // Output final product
    imagepng($base, $newcopy); //OUTPUT IMAGE

}

What I want to do add another value depending on the number of layers for the base image that is set in a database table. This is because there are images that have more than one layer of color.

so something like this:

public function layer_3($target, $NEWLAYER, $art, $newcopy, $r, $b, $g) {

    $artLayer = imagecreatefrompng($art); // Art Layer      
    $colorLayer1 = imagecreatefrompng($NEWLAYER); // NEW LAYER      
    $base = imagecreatefrompng($target); // Base Product
    $base_location = "base";

    $img = imagecreatefrompng($base);

    // NEW LAYER
    $width = imagesx( $colorLayer1 ); // colorLayer1
    $height = imagesy( $colorLayer1 ); // colorLayer1

    $width3 = imagesx( $artLayer ); // artLayer
    $height3 = imagesy( $artLayer ); // artLayer

    $img=imagecreatetruecolor( $width, $height ); // NEW LAYER

    imagealphablending($img, true); // NEW LAYER


    $transparent = imagecolorallocatealpha( $img, 0, 0, 0, 127 );
    imagefill( $img, 0, 0, $transparent );

    //COLOR THE IMAGE
    imagefilter($base, IMG_FILTER_COLORIZE, $r, $b, $g, 1); //the base  
    imagecopyresampled($img,$base,1,1,0,0, 1000, 1000, imagesx( $base ), imagesy( $base ) );            
    imagecopyresampled($img,$colorLayer1,1,1,0,0, 1000, 1000, imagesx( $colorLayer1 ), imagesy( $colorLayer1 )); //NEW LAYER    
    imagecopyresampled($img,$artLayer,300, 200, 0, 0, 350, 350, imagesx( $artLayer ), imagesy( $artLayer ));


    imagealphablending($img, false);
    imagesavealpha($img,true);
    imagepng($img, $newcopy);

}

  • 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-23T16:05:02+00:00Added an answer on May 23, 2026 at 4:05 pm

    As far I can see, the simplest way would be to use an array of layers as parameters, so the method signature will be:

    public function my_layers_func($target, $NEWLAYERS = array(), $art, $newcopy, $r, $b, $g) 
    

    And in your my_layers_func’s body, you should iterate on the $NEWLAYERS array applying the same transformations as you did on $NEWLAYER in layer_3 function.

    This is a sample of how you could refactor your function:

    public function my_layers_func($target, $newlayers = array(), $art, $newcopy, $r, $b, $g)
            $artLayer = imagecreatefrompng($art); // Art Layer   
        $colorLayers = array();
        foreach($newlayers as $newlayer){
            $colorLayers[] = imagecreatefrompng($newlayer); // NEW LAYER      
        }
            ....
    

    Let me know if you need more explanations!

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

Sidebar

Related Questions

James here. I'm working on a site that I want to have the same
Here's the issue: I have a list of App names that I want to
I have some classes that all implement a certain interface. I want to store
I have created a class that inherits the QListWidget and is meant to be
I have a sequence of ActiveRecord objects that I want to cascade destroy but
I want to have an option set before the Activity is created or at
I have a class that I've created to allow asynchronous sequential execution of tasks,
I want to have a singleton that holds some values S1 and S2 that
I have created a simple web crawler but I want to add the recursion
Placing an image inside a Span (here : HtmlGenericControl ) programmatically Want to have

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.