2013-03-12 3 views
2

У меня есть изображение, и я написал текст на этом изображении с помощью PHP «imagettftext» функции. теперь я не знаю, как это будет экономить автоматическое.как сохранить изображение после редактирования в PHP

header('Content-Type: image/png'); 
// Create the image 
$im = imagecreatefromjpeg('image-1.jpg'); 

// Create some colors 
$white = imagecolorallocate($im, 255, 255, 255); 
$grey = imagecolorallocate($im, 128, 128, 128); 
$black = imagecolorallocate($im, 0, 0, 0); 
//imagefilledrectangle($im, 0, 0, 399, 29, $white); 

// The text to draw 
$text = 'www.blockprintsonline.com'; 

// Replace path by your own font path 
$font = 'arial.ttf'; 

list($width, $height, $type, $attr) = getimagesize($get_image); 
$width1=$width*20/100; 
$height1=$height*50/100; 
$font_size=$width*4/100; 

// Add some shadow to the text 
//imagettftext($im, 30, 0, 11, 21, $grey, $font, $text); 

// Add the text 
imagettftext($im, $font_size, 0, $width1, $height1, $black, $font, $text); 

// Using imagepng() results in clearer text compared with imagejpeg() 
imagepng($im); 
imagedestroy($im); 

ответ

2

Если вы хотите, чтобы сохранить изображение в файл, проверьте документацию для imagepng() функции here.

Передавая имя файла в качестве второго аргумента он позволит сохранить изображение в файл, например:

imagepng($im, "path/to/save/image/in.png"); 
+0

thnx. он работает ... – Jitendra

0

Если вы обратитесь к документации по imagepng вы увидите, что вы можете предоставить имя файла. Это сохранит изображение на диск

+0

thnx. оно работает... – Jitendra

0
<?php 

// Save the image as 'simpletext.png' 
imagepng($im, 'simpletext.png'); 

// Free up memory 
imagedestroy($im); 
?> 

Это пример того, как сохранить изображение.

Смежные вопросы