Treinetic / ImageArtist

ImageArtist is a php gd Wrapper which makes Image manipulation insanely easy, we introduce ImageArtist as Photoshop for php
MIT License
82 stars 24 forks source link

Pink background instead of transparancy #17

Closed BrainFeeder closed 6 years ago

BrainFeeder commented 6 years ago

13 is about the same issue..

My transparent background color displays as pink.

merged

I wanted to do something like Facebook does for group chats: merging participant avatars to be one image. Code I have:

//$overlayWhite = new Overlay($size,$size,new Color(255,255,255)); I get the same if I use this instead of circle.png
$background = new CircularShape(FCPATH.'public/loremipsum/img/users/circle.png');
$background->build();

foreach($users as $i => $user) {
    $file = str_replace(img_url(), FCPATH.'public/loremipsum/img/', $user->getAvatar());
    $img = new Square($file);
    $img->setDefaults();
    $img->resize($size/2,$size/2);
    //$offsetX = ($img->getWidth()-$size)/2;
    //$offsetY = ($img->getHeight()-$size)/2;
    //$img->crop($offsetX , $offsetY, 32, 32); crop don't does what I expected... Probably beacause of #16 
    $img->build();

    switch($i) { $background = $background->merge($img,$w,$h); } // just to give an idea of merging, I select up to 4 avatars zo they get positioned in each corner of main image ($background).. 
    // This works so not showing all code

}
return $background->getDataURI();

And another unexpected behaviour: I hoped using circularShape would cut of corners from merged squares, so the resulting image would be a circle.

imalhasaranga commented 6 years ago

We'll investigate on the problem soon..

antondias commented 6 years ago

After building image :

$background->build();

it is just a image so you can't use it as circular shape.If you want to do that create square image by using your 4 images and pass it to circular shape. Upgrade to latest version and see if errors still there.

antondias commented 6 years ago

This is an example for create circular shape using 4 images :

image

    $img = new Square('./image1.jpg');
    $img->setDefaults();
    $img->resize($size/2, $size/2);
    $img->build();

    $img2 = new Square('./image2.jpg');
    $img2->setDefaults();
    $img2->resize($size/2, $size/2);
    $img2->build();

    $img3 = new Square('./image3.jpg');
    $img3->setDefaults();
    $img3->resize($size/2, $size/2);
    $img3->build();

    $img4 = new Square('./image4.jpg');
    $img4->setDefaults();
    $img4->resize($size/2, $size/2);
    $img4->build();

    $final = $img->merge($img2,125,0);
    $final = $final->merge($img3, 0,125);
    $image = $final->merge($img4,125,125);

    $circular = new CircularShape($image);
    $circular->build();
imalhasaranga commented 6 years ago

@BrainFeeder I think @antondias is correct, follow his code also please upgrade to latest ImageArtist Version, i'm closing this issue making as not reproducible issue