2011-10-04 3 views
1

Je viens de terminer ma classe pour rendre le texte de la marque d'eau sur l'imagecomment calculer où écrire un texte en filigrane dans ma classe

ici est mon problème

1 - utilisateur sélectionner le fichier de police

2 - utilisateur, sélectionnez la couleur de police

3 - select user position filigrane

4 - utilisateur choisir la taille de la police

Alors - mon problème est de savoir comment calculer la bonne position dépend de la taille de la police, la famille

voici mon code que je viens d'essayer

`

$ width = 400; // largeur de l'image

$ height = 300; // Hauteur de l'image

    if($this -> text_posi == 'topleft'){ 

        $x1 = ($width - $width) + 20; 
        $y1 = ($height - $height) + 40; 


        }elseif($this -> text_posi == 'topright'){ 

        $x1 = $width - 200; 
        $y1 = ($height - $height) + 40; 

        } 
        elseif($this -> text_posi == 'bottomleft'){ 

        $x1 = ($width - $width) + 20; 
        $y1 = $height - 30; 

        } 
        elseif($this -> text_posi == 'bottomright'){ 

        $x1 = $width - 200; 
        $y1 = $height - 30; 

        } 
        elseif($this -> text_posi == 'topcenter'){ 

        $x1 = $width * .5 - 100; 
        $y1 = ($height - $height) + 30; 

        } 
        elseif($this -> text_posi == 'bottomcenter'){ 

        $x1 = $width * .5 - 100; 
        $y1 = $height - 30; 

        } 
        elseif($this -> text_posi == 'rightcenter'){ 

        $x1 = $width - 180; 
        $y1 = $height * .5; 

        } 
        elseif($this -> text_posi == 'leftcenter'){ 

        $x1 = $width - $width + 20; 
        $y1 = $height * .5 ; 

        }else{ 

        $x1 = ($width/2) - 30; 
        $y1 = ($height/2) - 20 ; 
        } 

`

Je pense que ce bien si l'image plus que la largeur> = 500 et la hauteur> = 500

peut vous aider S'il vous plaît

Répondre

1

Détournez-vous de votre moniteur , prenez un crayon et un morceau de papier et dessinez quelques images:

watermark in the bottom-right corner 

      img_width 
      |----------- -----------------|<--| 
      |        | | 
      |        | | 
      |        | | 
      |        | | 
      |        | | mark Y offset 
img_height |        | | 
      |        | | 
      |        | | 
      |        | | 
      |    mark_width | | 
      |    |-------------|<--| 
      |    |    | 
      | mark_height |    | 
      |    |    | 
      |-----------------------------| 
      ^   ^
      |_______________| 
      mark X offset 

Il devrait être immedia Il est donc évident de calculer les valeurs des décalages X et Y. Pour savoir quelle est la taille du filigrane, utilisez http://www.php.net/manual/en/function.imagettfbbox.php

+0

Merci pour la réponse @stereofrog, donc imagettfbbox donnez-moi le x & y du mot je vais écrire sur l'image, merci – SamarLover

Questions connexes