File "image.php"

Full Path: /home/analogde/www/New/update/image.php
File size: 1.56 KB
MIME-type: text/plain
Charset: utf-8



<?php

$nom_image = "00.jpg";  // le nom de votre image avec l'extension jpeg
$texte = "votre texte";  // Le texte que vous désirez écrire sur l'image

//header ("Content-type: image/jpeg");
$image = imagecreatefromjpeg($nom_image);
/*$blanc = imagecolorallocate($image, 255, 255, 255);*/

$blanc = imagecolorallocate($image, 0, 0, 0);


imagestring($image, 5, 150, 150,$texte, $blanc);
imagejpeg($image, 'bof.jpg');

//array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
//$font = 'arial.ttf';

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

/* text over image 
header("Content-type: image/jpeg");
    $imgPath = 'image.jpg';
    $image = imagecreatefromjpeg($imgPath);
    $color = imagecolorallocate($image, 255, 255, 255);
    $string = "http://recentsolutions.net";
    $fontSize = 3;
    $x = 115;
    $y = 185;
    imagestring($image, $fontSize, $x, $y, $string, $color);
    imagejpeg($image);
*/




$ratio = .5;
// Calcul des nouvelles dimensions
list($largeur, $hauteur) = getimagesize("00.jpg"); //list est un moyen plus pratique pour ne récupérer que ce qu'on veut
$n_largeur = $largeur * $ratio;
$n_hauteur = $hauteur * $ratio;

//création de la destination
$destination = imagecreatetruecolor($n_largeur, $n_hauteur);

//on ouvre la source
$source = imagecreatefromjpeg("00.jpg");

// Redimensionnement
imagecopyresized($destination, $source, 0, 0, 0, 0, $n_largeur, $n_hauteur, $largeur, $hauteur);

imagejpeg($destination, "redim.jpg");

// GD library
?>