making mix image with gd











up vote
0
down vote

favorite












im trying to make a form with php and gd library.
form contains a png logo with transparent packgroung.
now i have 3 problems:




  1. when i make a border then i want to place the logo in top corner of
    image, its not transparented background anymore


  2. im using persian font and using imagettftext function. it show the
    characters but in persian we have merged words but it show
    characters seperated


  3. how can i draw rounded corner borders


here is my code:



$fontSize=4;
$width = imagefontwidth($font) * strlen($string)+10 ;
$height = imagefontheight($font) ;


$handle = ImageCreate (800, 400) or die ("Cannot Create image");
$logo = imagecreatefrompng( 'Logo.png' );

$bg_color = ImageColorAllocate ($handle, 255, 240, 250);
$txt_color = ImageColorAllocate ($handle, 0, 0, 0);

$title="فرم قرارداد";
$font = "IRANSans.ttf";
$title_size = 18;
imagettftext( $handle, $title_size, 0, 620, 100, $txt_color, $font, $title );

$black = imagecolorallocate($handle, 0, 0, 0);
imagerectangle($handle, 20, 20, 780, 380, $black);
imagecopy($handle, $logo, 10, 10, 0, 0, 161, 160);

header('Content-Type: image/png');
imagepng($handle);









share|improve this question


























    up vote
    0
    down vote

    favorite












    im trying to make a form with php and gd library.
    form contains a png logo with transparent packgroung.
    now i have 3 problems:




    1. when i make a border then i want to place the logo in top corner of
      image, its not transparented background anymore


    2. im using persian font and using imagettftext function. it show the
      characters but in persian we have merged words but it show
      characters seperated


    3. how can i draw rounded corner borders


    here is my code:



    $fontSize=4;
    $width = imagefontwidth($font) * strlen($string)+10 ;
    $height = imagefontheight($font) ;


    $handle = ImageCreate (800, 400) or die ("Cannot Create image");
    $logo = imagecreatefrompng( 'Logo.png' );

    $bg_color = ImageColorAllocate ($handle, 255, 240, 250);
    $txt_color = ImageColorAllocate ($handle, 0, 0, 0);

    $title="فرم قرارداد";
    $font = "IRANSans.ttf";
    $title_size = 18;
    imagettftext( $handle, $title_size, 0, 620, 100, $txt_color, $font, $title );

    $black = imagecolorallocate($handle, 0, 0, 0);
    imagerectangle($handle, 20, 20, 780, 380, $black);
    imagecopy($handle, $logo, 10, 10, 0, 0, 161, 160);

    header('Content-Type: image/png');
    imagepng($handle);









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      im trying to make a form with php and gd library.
      form contains a png logo with transparent packgroung.
      now i have 3 problems:




      1. when i make a border then i want to place the logo in top corner of
        image, its not transparented background anymore


      2. im using persian font and using imagettftext function. it show the
        characters but in persian we have merged words but it show
        characters seperated


      3. how can i draw rounded corner borders


      here is my code:



      $fontSize=4;
      $width = imagefontwidth($font) * strlen($string)+10 ;
      $height = imagefontheight($font) ;


      $handle = ImageCreate (800, 400) or die ("Cannot Create image");
      $logo = imagecreatefrompng( 'Logo.png' );

      $bg_color = ImageColorAllocate ($handle, 255, 240, 250);
      $txt_color = ImageColorAllocate ($handle, 0, 0, 0);

      $title="فرم قرارداد";
      $font = "IRANSans.ttf";
      $title_size = 18;
      imagettftext( $handle, $title_size, 0, 620, 100, $txt_color, $font, $title );

      $black = imagecolorallocate($handle, 0, 0, 0);
      imagerectangle($handle, 20, 20, 780, 380, $black);
      imagecopy($handle, $logo, 10, 10, 0, 0, 161, 160);

      header('Content-Type: image/png');
      imagepng($handle);









      share|improve this question













      im trying to make a form with php and gd library.
      form contains a png logo with transparent packgroung.
      now i have 3 problems:




      1. when i make a border then i want to place the logo in top corner of
        image, its not transparented background anymore


      2. im using persian font and using imagettftext function. it show the
        characters but in persian we have merged words but it show
        characters seperated


      3. how can i draw rounded corner borders


      here is my code:



      $fontSize=4;
      $width = imagefontwidth($font) * strlen($string)+10 ;
      $height = imagefontheight($font) ;


      $handle = ImageCreate (800, 400) or die ("Cannot Create image");
      $logo = imagecreatefrompng( 'Logo.png' );

      $bg_color = ImageColorAllocate ($handle, 255, 240, 250);
      $txt_color = ImageColorAllocate ($handle, 0, 0, 0);

      $title="فرم قرارداد";
      $font = "IRANSans.ttf";
      $title_size = 18;
      imagettftext( $handle, $title_size, 0, 620, 100, $txt_color, $font, $title );

      $black = imagecolorallocate($handle, 0, 0, 0);
      imagerectangle($handle, 20, 20, 780, 380, $black);
      imagecopy($handle, $logo, 10, 10, 0, 0, 161, 160);

      header('Content-Type: image/png');
      imagepng($handle);






      php gd






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 13:22









      hsoft

      205




      205
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted











          1. See this answer: php GD create a transparent png image

          2. You'll have to use an OpenType (.otf) font, if you want to make use of your language's typographic characteristics.

          3. You might want to take a look at GD's imagearc.






          share|improve this answer





















          • hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
            – hsoft
            Nov 20 at 14:20












          • about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
            – hsoft
            Nov 20 at 14:25












          • I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
            – Ro Achterberg
            Nov 21 at 10:09












          • thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
            – hsoft
            Nov 21 at 11:59












          • Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
            – Ro Achterberg
            Nov 21 at 13:11











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393961%2fmaking-mix-image-with-gd%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted











          1. See this answer: php GD create a transparent png image

          2. You'll have to use an OpenType (.otf) font, if you want to make use of your language's typographic characteristics.

          3. You might want to take a look at GD's imagearc.






          share|improve this answer





















          • hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
            – hsoft
            Nov 20 at 14:20












          • about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
            – hsoft
            Nov 20 at 14:25












          • I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
            – Ro Achterberg
            Nov 21 at 10:09












          • thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
            – hsoft
            Nov 21 at 11:59












          • Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
            – Ro Achterberg
            Nov 21 at 13:11















          up vote
          0
          down vote



          accepted











          1. See this answer: php GD create a transparent png image

          2. You'll have to use an OpenType (.otf) font, if you want to make use of your language's typographic characteristics.

          3. You might want to take a look at GD's imagearc.






          share|improve this answer





















          • hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
            – hsoft
            Nov 20 at 14:20












          • about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
            – hsoft
            Nov 20 at 14:25












          • I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
            – Ro Achterberg
            Nov 21 at 10:09












          • thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
            – hsoft
            Nov 21 at 11:59












          • Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
            – Ro Achterberg
            Nov 21 at 13:11













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted







          1. See this answer: php GD create a transparent png image

          2. You'll have to use an OpenType (.otf) font, if you want to make use of your language's typographic characteristics.

          3. You might want to take a look at GD's imagearc.






          share|improve this answer













          1. See this answer: php GD create a transparent png image

          2. You'll have to use an OpenType (.otf) font, if you want to make use of your language's typographic characteristics.

          3. You might want to take a look at GD's imagearc.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 13:33









          Ro Achterberg

          11819




          11819












          • hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
            – hsoft
            Nov 20 at 14:20












          • about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
            – hsoft
            Nov 20 at 14:25












          • I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
            – Ro Achterberg
            Nov 21 at 10:09












          • thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
            – hsoft
            Nov 21 at 11:59












          • Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
            – Ro Achterberg
            Nov 21 at 13:11


















          • hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
            – hsoft
            Nov 20 at 14:20












          • about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
            – hsoft
            Nov 20 at 14:25












          • I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
            – Ro Achterberg
            Nov 21 at 10:09












          • thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
            – hsoft
            Nov 21 at 11:59












          • Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
            – Ro Achterberg
            Nov 21 at 13:11
















          hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
          – hsoft
          Nov 20 at 14:20






          hi. thanks for the answer. about number 2 i convert my ttf to otf by an online tool but still get nothing
          – hsoft
          Nov 20 at 14:20














          about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
          – hsoft
          Nov 20 at 14:25






          about imagearc i searched. i think its possible to draw rounded corner square with line and arcs but it makes it hard for later changes.is there any simple function to draw square with round corners
          – hsoft
          Nov 20 at 14:25














          I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
          – Ro Achterberg
          Nov 21 at 10:09






          I'm not aware of such a function in the GD library. You may want to take a look at php.net/manual/en/class.imagickdraw.php. Font converters are notoriously unreliable. If I were you, I'd find a (licensed) OTF font that properly handles this for you out of the box.
          – Ro Achterberg
          Nov 21 at 10:09














          thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
          – hsoft
          Nov 21 at 11:59






          thanks again. i finaly solve the character problem with a library called persiangd.it support ttf and otf fonts.i will check your comment on imagickdraw and share the result.
          – hsoft
          Nov 21 at 11:59














          Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
          – Ro Achterberg
          Nov 21 at 13:11




          Cool, good luck. If you found my answer helpful, please consider marking it as the accepted answer :). Thank you.
          – Ro Achterberg
          Nov 21 at 13:11


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393961%2fmaking-mix-image-with-gd%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Feedback on college project

          Futebolista

          Albești (Vaslui)