Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Thanked 1 Time in 1 Post

    Adding GD watermark fails.

    I'm trying to add a watermark on one of my pictures on my hdd. Therefor I'm using this coding:

    PHP Code:
        $stamp imagecreatefrompng('logo.png');
    $im imagecreatefromjpeg($PreviewImageName);

    $marge_right 10;
    $marge_bottom 10;
    $sx imagesx($stamp);
    $sy imagesy($stamp);

    imagecopy($im$stampimagesx($im) - $sx $marge_rightimagesy($im) - $sy $marge_bottom00imagesx($stamp), imagesy($stamp));

    header('Content-type: image/png');
    I'm getting strange results, like this:
    ����JFIF��>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ��C	    $.' ",#(7),01444'9=82<.342��C	  2!!22222222222222222222222222222222222222222222222222��w�"��	 ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1AQaq"2�B����	#3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?��ڤ�E< ��)qJ(LPiؤ"���Y�/��x:ے�.x�O���4tS���y5���R̙h��b�= 0(��Uf^3WT�� 3�����Z�+.^�ԏ�S�(BQ0�M1��TMަn F�Tn*V��@��¯�*�uE7�Qy$t��O�kO2�u�X���\��HBm(z�Kg�+�A��z�y�i����܉P��(�Wn{Ӽ����ܤ��e`G�P����`��S���K�������ڤ��H�|ô����X.k۽��[�%S����������eL#���<�V����d��+ ���Z����� ^���eq�s�s�.|�Y6�Z�/-��.�8ϵ ��Sq��b��rpb�eh��>=k�K�T�P�L��p�GQ_�o������,Ok:ݣ8�>��`�8�*��Yz�`��^��ւ�+��
    I dunno where it goes wrong, but the logo ain't added to the picture at all. Can anyone tell me where it goes wrong, and what I could do to make this work?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,660 Times in 2,629 Posts
    The header you have there is invalid. Your output source is a JFIF (jpeg), not a PNG. Change the header and see if it correct the output. What you are seeing is the ascii representation of the binary, and since the header isn't correctly interpreting the type of file it is, it keeps looking for the PNG header which it'll never find. If its embedded in html, you should see a broken image link instead of the output.
    You can also get this problem if you have an issue setting the header at all and it outputs it just as text.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    docock (04-05-2013)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts