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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:01:43+00:00 2026-06-09T22:01:43+00:00

So I downloaded and edited a script off the internet to pull an image

  • 0

So I downloaded and edited a script off the internet to pull an image and find out the hex values it contains and their percentages:

The script is here:

<?php
$delta = 5;
$reduce_brightness = true;
$reduce_gradients = true;
$num_results = 5;

include_once("colors.inc.php");
$ex=new GetMostCommonColors();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Colour Verification</title>

</head>
<body>
    <div id="wrap">
    <img src="http://www.image.come/image.png" alt="test image" />
    <?php
        $colors=$ex->Get_Color("http://www.image.come/image.png", $num_results, $reduce_brightness, $reduce_gradients, $delta);
        $success = true;
        foreach ( $colors as $hex => $count ) {
            if ($hex !== 'e6af23') {$success = false; }
        if ($hex == 'e6af23' && $count > 0.05) {$success = true; break;}
        }

        if ($success == true) { echo "This is the correct colour. Success!"; } else { echo "This is NOT the correct colour. Failure!"; }


?>
    </div>

</body>
</html>

Here is a pastebin link to the file colors.inc.php

http://pastebin.com/phUe5Pad

Now the script works absolutely fine if I use an image that is on the server, eg use /image.png in the Get_Color function. However, if I try and use an image from another website including a http://www.site.com/image.png then the script no longer works and this error appears:

Warning: Invalid argument supplied for foreach() in … on line 22

Is anyone able to see a way that I would be able to hotlink to images because this was the whole point of using the script!

  • 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-09T22:01:44+00:00Added an answer on June 9, 2026 at 10:01 pm

    You must download a file to the server and pass its full filename to the method Get_Color($img) as $img parameter.

    So, you need to investigate another SO question: Download File to server from URL

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

Sidebar

Related Questions

I downloaded and edited a code that from internet, basically what I want to
Just downloaded Quartz.Net, read the documentation which is out of date and have ended
I downloaded the kernel source for htc explorer (pico-gb-crc-2.6.38-71ff0f2). But I cannot find the
I have a process where a CSV file can be downloaded, edited then uploaded
i downloaded a facebook-like chat application, i edited it to fit for my website
Lets say I did a check out, edited some stuff and realized I want
I downloaded a php code from internet for apple push notification at the beginning
[edited] I am trying to make a script that downloads a file, the problem
I'd like to try this out, downloaded it , read the readme, referenced the
Downloaded Reachability from Apple, using this method to check for an active connection: -(BOOL)isReachable{

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.