Article written by

3 Responses

Page 1 of 1
  1. Daniel Antonin Black
    Daniel Antonin Black at | | Reply

    Very cool work. Is this on github anywhere?

  2. Martijn
    Martijn at | | Reply

    Minor tweak to the getMosaic function, which lets GD resample the image to the final pixel dimensions. This does a few things in one step; fix the offset issue with imagecolorat(), interpolation and faster than handling interpolation manually.

    function getMosaic() {
    $resource = imagecreatefromstring(file_get_contents($this->imageURL));
    $scale_w = round($this->w / $this->sharpness);
    $scale_h = round($this->h / $this->sharpness);
    $resampled = imagecreatetruecolor($scale_w, $scale_h);
    imagecopyresampled($resampled, $resource, 0, 0, 0, 0, $scale_w, $scale_h, $this->w, $this->h);

    $class = $this->getClass();
    $mosaic = ‘w . ‘” height=”‘ . $this->h . ‘” cellspacing=”0″ cellpadding=”0″ border=”0″ bgcolor=”#fefefe” class=”‘ . $class . ‘”>’;
    $mosaic .= ”;
    for ($y = 0; $y < $scale_h; $y++) {
    $mosaic .= '’;
    for ($x = 0; $x rgb2hex($rgba);
    $mosaic .= ‘sharpness . ‘” bgcolor=”‘ . $colour_string . ‘”>‘ . PHP_EOL;
    }
    $mosaic .= ” . PHP_EOL;
    }
    $mosaic .= ”;
    $mosaic .= ”;

    return $mosaic;
    }

    Did you ever manage to fix the Oultook issues?

    I’d like to use this class, after applying some other improvements; Imagick support, merging cells with identical or similar colors (already had this working for an image slicer) and alternative pictures for no-image/image modes.

Leave a Reply