coldume / imagecraft

A reliable and extensible PHP image manipulation library
MIT License
101 stars 28 forks source link

Background layer tansparency problem. #11

Closed Nialcen closed 9 years ago

Nialcen commented 9 years ago

Hello, first of all, thank you so much, this is wonderfull !

I have only one litlle probleme. As I use a .png with transparent background as addBackgroundLayer , the transparency seems not to be handled.

coldume commented 9 years ago

Hi, thanks for reporting this bug, it seems to be caused by a recent pull request, please cd your <your_project>/vendor/coldume/imagecraft/ directory and paste the following command

git branch revert 3786b26b0bb2fae3ad815d1eafec99adeae4f5f8 && git checkout revert

does this fix your problem? Need your feedback, thanks.

Nialcen commented 9 years ago

I use ssh session with putty :

/imagecraft/vendor/coldume/imagecraft > git branch revert 3786b26b0bb2fae3ad815d1eafec99adeae4f5f8 && git checkout revert fatal: Not a git repository (or any parent up to mount parent ) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

May I ask you a direct link for an archive of the corrected files ?

I have another question, not linked to the current bug, where can I ask ?

coldume commented 9 years ago

How did you install imagecraft? from archive file or composer? Also, you can just ask questions here.

Nialcen commented 9 years ago

I used an archive file (http://www.imagecraft.cc/web/archive/imagecraft.zip).

It's much more a request than a question but : I use your work to produce animated gif too, wich work flowlessly. However, .gif loose a bit of quality ( normal thing ) and some users start asking .webp format file, that allow animation, but without this much quality lost. I would like to know if you have planed to add an option to save as .webp ? Or not at all ?

Another little thing, but idk if it's from imagecraft or .gif itself : as I use .png as image layer on an animated .gif, if this .png image as shadow using semi-transparency, those shadows do not have proper transparency, creating block color instead.

coldume commented 9 years ago

If you are using the archive file, it should have no problem, may I have your png file that caused the issue? It would be a great sample.

Imagecraft supports some webp images, excluding animated webp. As GD library does not natively support animated webp, and there's little documentation about webp, so I won't write a patch for it.

For your second question, it is an intended behavior, as GIF does not support semi-transparency, and you are putting a PNG on a GIF. See image below: b09oz I recommend you to use GIF as your watermark, and the problem will gone.

Nialcen commented 9 years ago

So the image : http://www.tree-of-savior.fr/wp-content/uploads/2015/09/Sign_1.png : I use it as a background layer, on wich I add other .png as layers.

Thank you for all informations !

coldume commented 9 years ago

Cool, I will examine the image tonight.

Nialcen commented 9 years ago

I actualy save my png browser side, so the quality is not this good : with image craft the quality is perfect, however, it's on blackbackground^^

coldume commented 9 years ago

I used the example.php file in the archive, changing the path pikachu.gif to Sign_1.png. Here is the output, it seems ok: output What is your output if you do the same on your server?

Nialcen commented 9 years ago

Well :

Here is the result, nialcen-1441782129

here is the script I use :

$image = $builder
        ->addBackgroundLayer()
            ->filename($signatureFond)
            ->done()
        ->addImageLayer()
            ->filename($face)
            ->resize(100, 150, 'shrink')
            ->move(0, 0, 'top_left')
            ->done()
        ->addImageLayer()
            ->filename($hair)
            ->resize(100, 150, 'shrink')
            ->move(0, 0, 'top_left')
            ->done()
        ->addImageLayer()
            ->filename($hat)
            ->resize(100, 150, 'shrink')
            ->move(0, 0, 'top_left')
            ->done()
        ->addImageLayer()
            ->filename($logo)
            ->move(0, 0, 'top_left')
            ->done()
        ->addTextLayer()
            ->font(__DIR__.'/fonts/amarante.ttf', 30, '#FFF')
            ->label($texte)
            ->box($paddings,$color = null)
            ->done()
        ->save()
    ;

if ($image->isValid()) {
        file_put_contents($themeRoot . '/signatures/' . $fileName . '.' . $image->getExtension(), $image->getContents());
        echo 'http://www.tree-of-savior.fr/wp-content/themes/_tk-master/signatures/' . $fileName . '.' . $image->getExtension() ;
    } 
else {
    echo 'ERROR' ;
    echo $image->getMessage().PHP_EOL;
}

Here are the layers I use : $signatureFond : http://www.tree-of-savior.fr/wp-content/uploads/2015/09/Sign_1.png $face : http://www.tree-of-savior.fr/wp-content/uploads/2015/09/Visage_m.png $hair : http://www.tree-of-savior.fr/wp-content/uploads/2015/09/DraTail_m.png $hat : http://www.tree-of-savior.fr/wp-content/uploads/2015/09/hat_0.png $logo : http://www.tree-of-savior.fr/wp-content/uploads/2015/09/Swordman.png $text : Nialcen

So you have all the pieces, the script, and the result I obtain.

coldume commented 9 years ago

Yes, bug confirmed, gonna fix this issue soon.

Nialcen commented 9 years ago

May I ask you the origin of this ( just curious to understand ). I will have to update some files ?

coldume commented 9 years ago

I'm not sure where the bug come from yet, but you don't have to update any of your files, the API of imagecraft won't change.

Nialcen commented 9 years ago

Ok, I'll check asa you let me know it's corrected, thank you for you reactivity

coldume commented 9 years ago

Bug fixed. I have also updated the archive file.

Nialcen commented 9 years ago

Ok, so should I update my files too ?

coldume commented 9 years ago

Yes, please

Nialcen commented 9 years ago

Thank you !