Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple overlay #281

Open
Eugene-nsk opened this issue Apr 28, 2021 · 2 comments
Open

Multiple overlay #281

Eugene-nsk opened this issue Apr 28, 2021 · 2 comments

Comments

@Eugene-nsk
Copy link

How about add the multiple as $anchor in overlay() such as

@maPer77
Copy link
Contributor

maPer77 commented Apr 28, 2021

This should be what you need, do a test, I use it this way ... I got a piece of my code, I haven't tested it, but it should work ..
$transparency = a value from 0 to 100

// ############### APPLY TEXTURE
function applyTexture($imagem, $textura, $texturaTransparencia) {
    $imgLargura = $imagem->getWidth();
    $imgAltura = $imagem->getHeight();
    list($texLargura, $teximgAltura) = getimagesize($textura);
    $x = ceil( $imgLargura / $texLargura );
    $y = ceil( $imgAltura / $teximgAltura );
    for ($linha = 0; $linha < $y; $linha++):
        for ($coluna = 0; $coluna < $x; $coluna++):
            $imagem->overlay($textura, 'top left', (100-$texturaTransparencia)/100, ($coluna*$texLargura), ($linha*$teximgAltura));
        endfor;
    endfor;
};
$image = new \claviska\SimpleImage();
$image->fromFile("../url/to/image/image.jpg");
$texture = "../url/to/texture/image.png";
applyTexture($image, $texture, $transparency);

@maPer77
Copy link
Contributor

maPer77 commented Apr 28, 2021

I want to do a PR for this functionality as soon as I have some free time ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants