changing image colors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michel

    changing image colors

    Hi folks,

    I wonder if what I have in mind is possible, maybe even not all that
    complicated:

    I have an image, which is a yellow circle. I want this yellow circle to
    change color by having 3 sliders (RGB) on a website and a button to process
    it.

    Is this at all possible and could someone point me in the right direction or
    a script that does this?

    Thank you,

    Michel


  • Geoff Berrow

    #2
    Re: changing image colors

    I noticed that Message-ID: <d9h4vs$t2f$1@n ews.cistron.nl> from Michel
    contained the following:
    [color=blue]
    >I have an image, which is a yellow circle. I want this yellow circle to
    >change color by having 3 sliders (RGB) on a website and a button to process
    >it.
    >
    >Is this at all possible and could someone point me in the right direction or
    >a script that does this?[/color]

    Flash?

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • dracolytch

      #3
      Re: changing image colors

      Flash is one solution... From an interface perspective, probably the
      best. Not everyone has the cash for a copy of flash though.

      Here's another one which will at first seem backward, but is nice and
      sneaky, and doesn't require flash:

      Make a table, and put in it a transparent gif. The gif is actually
      white with a transparent circle in the middle.

      Make the background color of the table yellow.

      Use whatever input you find convenient to create controls that, using
      JavaScript, change the background color of the table.

      ~D

      Comment

      • Michel

        #4
        Re: changing image colors

        Okay.... I need 65000 variations, premade....
        So a script that wanders through the colors and changes a template and saves
        it.
        That would be ideal.....


        "dracolytch " <dracolytch@gma il.com> wrote in message
        news:1119643274 .926864.96110@g 47g2000cwa.goog legroups.com...[color=blue]
        > Flash is one solution... From an interface perspective, probably the
        > best. Not everyone has the cash for a copy of flash though.
        >
        > Here's another one which will at first seem backward, but is nice and
        > sneaky, and doesn't require flash:
        >
        > Make a table, and put in it a transparent gif. The gif is actually
        > white with a transparent circle in the middle.
        >
        > Make the background color of the table yellow.
        >
        > Use whatever input you find convenient to create controls that, using
        > JavaScript, change the background color of the table.
        >
        > ~D
        >[/color]


        Comment

        • Andy Hassall

          #5
          Re: changing image colors

          On Fri, 24 Jun 2005 16:22:52 +0200, "Michel" <no@spam.please > wrote:
          [color=blue]
          >I wonder if what I have in mind is possible, maybe even not all that
          >complicated:
          >
          >I have an image, which is a yellow circle. I want this yellow circle to
          >change color by having 3 sliders (RGB) on a website and a button to process
          >it.
          >
          >Is this at all possible and could someone point me in the right direction or
          >a script that does this?[/color]

          Depends when you want the image to change. The PHP answer is that you have to
          submit the form back to PHP each time you want the image to change, so PHP can
          regenerate it and send it back.

          Another snag is that HTML forms don't include slider controls, so you'd have
          to have something else like a series of radio buttons or an input box with a
          number in it.

          circle.php :

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
          <html>
          <head>
          <title>circle </title>
          </head>
          <body>
          <?php
          $r = isset($_GET['r']) ? (int)$_GET['r'] : 255;
          $g = isset($_GET['g']) ? (int)$_GET['g'] : 255;
          $b = isset($_GET['b']) ? (int)$_GET['b'] : 0;
          print "<img src='image.php? r=$r&amp;g=$g&a mp;b=$b' alt=''>";
          ?>

          <form method='get' action='circle. php'>
          R<input type='text' name='r' value='<?php print $r; ?>' size='3'>
          G<input type='text' name='g' value='<?php print $g; ?>' size='3'>
          B<input type='text' name='b' value='<?php print $b; ?>' size='3'>
          <input type='submit' value='process' >
          </form>

          </body>
          </html>


          image.php :

          <?php
          $im = imagecreate(96, 96);
          $white = imagecoloralloc ate($im, 255, 255, 255);

          $r = (int)$_GET['r'];
          $g = (int)$_GET['g'];
          $b = (int)$_GET['b'];

          $fill = imagecoloralloc ate($im, $r, $g, $b);

          imagefilledelli pse($im, 48, 48, 96, 96, $fill);

          header('Content-type: image/png');
          imagepng($im);
          ?>

          Another approach could be Javascript based, changing the src attribute of an
          <img> tag in response to user input to call a PHP script with parameters
          controlling the image colour.

          --
          Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
          <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

          Comment

          • Michel

            #6
            Re: changing image colors

            Hi Andy,

            Great help this is indeed....
            But... this creates a new image.
            Is it possible to change the color of an existing image too?

            Thanks,

            MIchel

            "Andy Hassall" <andy@andyh.co. uk> wrote in message
            news:c3mqb1prpr q2451gbrahhk3tj v1tahacqh@4ax.c om...[color=blue]
            > On Fri, 24 Jun 2005 16:22:52 +0200, "Michel" <no@spam.please > wrote:
            >[color=green]
            > >I wonder if what I have in mind is possible, maybe even not all that
            > >complicated:
            > >
            > >I have an image, which is a yellow circle. I want this yellow circle to
            > >change color by having 3 sliders (RGB) on a website and a button to[/color][/color]
            process[color=blue][color=green]
            > >it.
            > >
            > >Is this at all possible and could someone point me in the right direction[/color][/color]
            or[color=blue][color=green]
            > >a script that does this?[/color]
            >
            > Depends when you want the image to change. The PHP answer is that you[/color]
            have to[color=blue]
            > submit the form back to PHP each time you want the image to change, so PHP[/color]
            can[color=blue]
            > regenerate it and send it back.
            >
            > Another snag is that HTML forms don't include slider controls, so you'd[/color]
            have[color=blue]
            > to have something else like a series of radio buttons or an input box with[/color]
            a[color=blue]
            > number in it.
            >
            > circle.php :
            >
            > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            > "http://www.w3.org/TR/html4/loose.dtd">
            > <html>
            > <head>
            > <title>circle </title>
            > </head>
            > <body>
            > <?php
            > $r = isset($_GET['r']) ? (int)$_GET['r'] : 255;
            > $g = isset($_GET['g']) ? (int)$_GET['g'] : 255;
            > $b = isset($_GET['b']) ? (int)$_GET['b'] : 0;
            > print "<img src='image.php? r=$r&amp;g=$g&a mp;b=$b' alt=''>";
            > ?>
            >
            > <form method='get' action='circle. php'>
            > R<input type='text' name='r' value='<?php print $r; ?>' size='3'>
            > G<input type='text' name='g' value='<?php print $g; ?>' size='3'>
            > B<input type='text' name='b' value='<?php print $b; ?>' size='3'>
            > <input type='submit' value='process' >
            > </form>
            >
            > </body>
            > </html>
            >
            >
            > image.php :
            >
            > <?php
            > $im = imagecreate(96, 96);
            > $white = imagecoloralloc ate($im, 255, 255, 255);
            >
            > $r = (int)$_GET['r'];
            > $g = (int)$_GET['g'];
            > $b = (int)$_GET['b'];
            >
            > $fill = imagecoloralloc ate($im, $r, $g, $b);
            >
            > imagefilledelli pse($im, 48, 48, 96, 96, $fill);
            >
            > header('Content-type: image/png');
            > imagepng($im);
            > ?>
            >
            > Another approach could be Javascript based, changing the src attribute of[/color]
            an[color=blue]
            > <img> tag in response to user input to call a PHP script with parameters
            > controlling the image colour.
            >
            > --
            > Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
            > <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool[/color]


            Comment

            • Andy Hassall

              #7
              Re: changing image colors

              On Sat, 25 Jun 2005 15:49:08 +0200, "Michel" <no@spam.please > wrote:
              [color=blue]
              >Is it possible to change the color of an existing image too?[/color]

              If you've got a paletted image, then:



              Otherwise:



              --
              Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
              <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

              Comment

              • Michel

                #8
                Re: changing image colors

                Great stuff..... now it's back to the drawing board for me. Lemmie
                experiment with that for a while.

                Many thanks!

                Michel

                "Andy Hassall" <andy@andyh.co. uk> wrote in message
                news:ne6rb1pqju c07a7msg95e6l4v im7p691c9@4ax.c om...[color=blue]
                > On Sat, 25 Jun 2005 15:49:08 +0200, "Michel" <no@spam.please > wrote:
                >[color=green]
                > >Is it possible to change the color of an existing image too?[/color]
                >
                > If you've got a paletted image, then:
                >
                > http://uk2.php.net/manual/en/function.imagecolorset.php
                >
                > Otherwise:
                >
                > http://uk2.php.net/manual/en/function.imagefill.php
                >
                > --
                > Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
                > <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool[/color]


                Comment

                Working...