Jump to content

zq29

Staff Alumni
  • Posts

    2,752
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by zq29

  1. [quote author=tomfmason link=topic=103258.msg411085#msg411085 date=1154944568]
    I tried using
    [code=php:0]
    chdir ($file_system_path);
    exec ("del *.* /s /q");[/code]

    And it delted everything in the current directory that I had the file that was running the code. It is a damn good thing that I used a test directory in local host..lol

    This is dangerous if you do not know what you are doing.

    Thanks,
    Tom
    [/quote]
    Indeed. '*.*' will delete all files with an extension as the * character is used as a wildcard, /s flags all sub-directories for deletion, and /q runs in quiet mode - just deleting without prompting.
  2. the '$' symbol is a special character when working with Regular Expressions - Escape it and you should be fine.
    [code]<?php
    $val1 = "{BODY}";
    $val2 = '\$453.00';

    echo preg_replace('/{BODY}/',$val2,$val1);
    ?>[/code]
  3. [quote author=dagnasty link=topic=103226.msg411028#msg411028 date=1154933097]
    intimidating at first, but in no time you'll be stripping data and posting forms from a php script.

    Need help with it, just give me a PM?
    [/quote]
    As far as I'm aware our PM system is currently disabled. Even if it wasn't, please keep all technical discussions in the forum - It may help someone else out in the future.
  4. [quote author=onlyican link=topic=103079.msg410263#msg410263 date=1154795844]
    You can find the pixel color from an image, and replace it with your color

    I have seen one script which replaces all "Non Internet Safe" colors with "Internet Safe" colors, and let me tell ya, it was a good script, but the images came out really really bad
    [/quote]I know how to find a pixels colour, my script above demonstrates that ;)

    [quote author=Barand link=topic=103079.msg410301#msg410301 date=1154801369]
    imagecolorset() changes the pallete so one change there affects the whole image
    [/quote]Yeah, that works fine with gifs and 8-bit pngs, but unfortunately I'm working with true colour jpegs. This is why I am using a threshold so that I am replacing a 'range' of slightly different colours with their counterpart replacement colours.

    I'm getting closer to solving my problem I think, but still a long way off - I have been tinkering with this on and off for weeks...
  5. Hi everyone,

    I have found the need to be able to change a specific colour within a photograph automatically with PHP (and GD). My progress so far has enabled me to change the [i]hue[/i] of a specific colour, but I need to be able to change the [i]saturation[/i] and the [i]brightness[/i] as well. This is where I appear to be hitting a wall, and I'm struggling to figure it out - Might have something to do with my poor maths skills ;). Hopefully somone could offer me some usefull pointers on how I might go about this. Here is my function so far...
    [code]<?php
    function recolor($file,$colortochange,$newcolor) {
        $threshold = 30;

        $image = imagecreatefromjpeg($file);
        $width = imagesx($image);
        $height = imagesy($image);

        $c1 = sscanf($colortochange,"%2x%2x%2x");
        list($huetoreplace,$sattoreplace,$valtoreplace) = rgbtohsv($c1[0],$c1[1],$c1[2]);

        $c2 = sscanf($newcolor,"%2x%2x%2x");
        list($newhue,$newsat,$newval) = rgbtohsv($c2[0],$c2[1],$c2[2]);

        for($y=0; $y<$height; $y++) {
            for($x=0; $x<$width; $x++) {
                $rgb = imagecolorat($image,$x,$y);
                $a = ($rgb >> 24) & 0xFF;
                $r = ($rgb >> 16) & 0xFF;
                $g = ($rgb >> 8) & 0xFF;
                $b = $rgb & 0xFF;
                list($h,$s,$v) = rgbtohsv($r,$g,$b);

                $angle = ($h >= $huetoreplace) ? 360 - ($h - $huetoreplace) : 360 - ($huetoreplace - $h);
                $angle = ($angle > 180) ? 360 - $angle : $angle;

                if($angle <= $threshold) {
                    $h = $newhue + ($h - $huetoreplace);
                    if($h < 0) $h += 360;
                    if($h > 360) $h -= 360;

    /*              $s = $newsat + ($s - $sattoreplace);
                    if($s < 0) $s = 0;
                    if($s > 100) $s = 100;

                    $v = $newval + ($v - $valtoreplace);
                    if($v < 0) $v = 0;
                    if($v > 100) $v = 100;
    */
                    list($r,$g,$b) = hsvtorgb($h,$s,$v);
                    $color = imagecolorallocatealpha($image,$r,$g,$b,$a);
                    imagesetpixel($image,$x,$y,$color);
                }
            }
        }

        header("Content-Type: image/jpeg");
        imagejpeg($image);
    }
    ?>[/code]

    The above works lovely, replacing the hues where it should. But when I add in the code to alter the saturation and brightness (value), I get some wierd results, such as 'blocks' of colour and random colours here and there. I just can't figure it out.

    There are two functions used in the above code that I haven't added, but they are just for converting RGB to HSV and visa-versa. And yes, this function does loop through an image pixel by pixel, if you have any other ideas on how to do this, they would also be appreciated as this method is slow, but it gets the job done (at its current stage).

    If anyone needs help understanding my code so far, I can comment it if need be, let me know.

    Any help is very much appreciated. :)
  6. One option could be to create a 'count' field in your table. Every time a user is assigned to a 'job' increment their count, when selecting a user for a 'job', order the results by the 'count' field and select the user with the lowest count.
  7. As far as I'm aware, Safari is based on the KHTML engine - The same as Konqueror which is generaly packaged with Linux installs running KDE. It is possible to get Konqueror running on WinXP, but I'm not sure how easy it is - A quick search on Google will show you how.

    It might be just easier to burn off a copy of Knoppix.

    Do mac users activly use Safari? I use on FireFox on mine...
  8. As part of a project, I need the user to be able to place a 'marker' on top of an image, and to do this I need to location of the mouse relative to the top left of the image (contained within a div). My current solution gets the mouse position relative to the page and then offsetting it agains the position of the image div - As you are probably aware, this is not ideal for several reasons. I'd class myself as somewhat of a novice at JavaScript as I don't really use it on a daily basis. Any help with this would be appreciated. My current function:
    [code]function getcoords(id,tgt) {
        var posX = 0;
        var posY = 0;
        var exit = 0;

        document.getElementById(tgt).onmousemove = getMouseXY;
        document.getElementById(tgt).onclick = storeMouseXY;

        function getMouseXY(e) {
            if(exit == 0) {
                if(navigator.appName == "Netscape"){
                    posX = e.pageX;
                    posY = e.pageY;
                } else {
                    posX = event.clientX + document.body.scrollLeft;
                    posY = event.clientY + document.body.scrollTop;
                }
                if (posX <= 0) {posX = 0;}
                if (posY <= 0) {posY = 0;}
                var pos = (posX - 494)+","+(posY - 157);
                document.getElementById(id).value = pos;
            }
        }

        function storeMouseXY() {
            var pos = (posX - 494)+","+(posY - 157);
            document.getElementById(id).value = pos;
            exit = 1;
        }
    }[/code]
  9. I have just edited out the vulgar words in 6 of the above posts in this thread. Please refrain from using such words in future, they were not necessary to convey your problem. We do have minors browsing the forum, and yes, they probably have heard those words a million times before elsewhere, but thats not the point.
  10. Ok, here's my list, a bit of a range of different styles in there I think:

    [0] A Tribe Called Quest
    [0] Alicia Keys
    [0] Basement Jaxx
    [0] Blackalicious
    [0] Bob Marley
    [0] Christina Aguilera
    [0] Citizen Cope
    [0] De La Soul
    [0] Dead Prez
    [0] Dillated Peoples
    [0] DJ Format
    [0] DJ Shadow
    [0] DJ Z-Trip
    [0] Fatboy Slim
    [0] Feeder
    [0] Fugees
    [0] Gavin DeGraw
    [0] Green Day
    [0] Hieroglyphics
    [0] Jurassic 5
    [0] Maroons
    [0] Macy Gray
    [0] Mos Def
    [0] No Doubt
    [0] Oasis
    [0] Phantom Planet
    [0] Prodigy
    [0] Ray Charles
    [0] Reel Big Fish
    [0] Talib Kweli
    [0] Tenacious D
    [0] The Roots
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.