Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Dodanie tekstu do obrazka
reyne
post
Post #1





Grupa: Zarejestrowani
Postów: 73
Pomógł: 1
Dołączył: 19.12.2007

Ostrzeżenie: (0%)
-----


Witam, mam gotowy skrypt który dodaje znak wodny do obrazka. Mam pytanie jak dodać jeszcze na niego dowolny tekst zawarty w zmiennej?

  1. $file = imagecreatetruecolor($width, $height);
  2. $new = imagecreatefromjpeg($this->file_tempname);
  3. for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); }
  4. imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height);
  5.  
  6. $watermark = @imagecreatefrompng('watermark.png');
  7. $imagewidth = imagesx($file);
  8. $imageheight = imagesy($file);
  9. $watermarkwidth = imagesx($watermark);
  10. $watermarkheight = imagesy($watermark);
  11. $startwidth = (($imagewidth - $watermarkwidth)/1);
  12. $startheight = (($imageheight - $watermarkheight)/1);
  13.  
  14. imagecopy($file, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
  15. imagejpeg($file, $photo_dest, 100);
  16. ImageDestroy($new);
  17. ImageDestroy($file);
  18. imagedestroy($watermark);
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
bemol
post
Post #2





Grupa: Zarejestrowani
Postów: 286
Pomógł: 29
Dołączył: 5.04.2007
Skąd: Rymanów Zdrój/Rzeszów

Ostrzeżenie: (0%)
-----


Użyj tej funkcji:
imagettftext
lub tej:
imagefttext

Ten post edytował bemol 7.11.2010, 23:19:13


--------------------
Tym ludziom zaufałem i dobrze na tym wyszedłem:
kresh
Darti
piotrekkr
Bez nich wiele bym nie zrobił. Dzięki im za to!
Go to the top of the page
+Quote Post
reyne
post
Post #3





Grupa: Zarejestrowani
Postów: 73
Pomógł: 1
Dołączył: 19.12.2007

Ostrzeżenie: (0%)
-----


Ok zrobiłem tak i śmiga smile.gif :


  1. $file = imagecreatetruecolor($width, $height);
  2. $new = imagecreatefromjpeg($this->file_tempname);
  3. for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); }
  4. imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height);
  5.  
  6. $watermark = @imagecreatefrompng('watermark.png');
  7. $imagewidth = imagesx($file);
  8. $imageheight = imagesy($file);
  9. $watermarkwidth = imagesx($watermark);
  10. $watermarkheight = imagesy($watermark);
  11. $startwidth = (($imagewidth - $watermarkwidth)/1);
  12. $startheight = (($imageheight - $watermarkheight)/1);
  13. ///
  14. $black = imagecolorallocate($file, 0xff, 0xff, 0xff);
  15. // Path to our ttf font file
  16. $font_file = './arial.ttf';
  17. $text = 'autor: '.$author.'';
  18. // Draw the text 'PHP Manual' using font size 13
  19. imagefttext($file, 13, 0, 105, 55, $black, $font_file, $text);
  20. ///
  21. imagecopy($file, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
  22. imagejpeg($file, $photo_dest, 100);
  23. ImageDestroy($new);
  24. ImageDestroy($file);
  25. imagedestroy($watermark);
  26. break;


Ten post edytował reyne 8.11.2010, 01:31:27
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 00:01