0
J'ai une image: image (peut être au format JPG ou GIF)Comment dessiner un carré 8x8 sur une image?
Comment puis-je dessiner un carré 8x8 à $x, $y
puis enregistrez l'image à $file
?
J'ai une image: image (peut être au format JPG ou GIF)Comment dessiner un carré 8x8 sur une image?
Comment puis-je dessiner un carré 8x8 à $x, $y
puis enregistrez l'image à $file
?
Vous recherchez imagerectangle()
:
// Load the image
$img = imagecreatefrompng("image.png"); // or imagecreatefromjpeg(), etc.
// Set a colour for the sides of the rectangle
$color = imagecolorallocate($img, 255, 255, 255); // for a white rectangle
// Draw an 8x8 recangle at coordinates ($x, $y) from top left
imagerectangle($img, $x, $y, $x+8, $y+8, $color);
// Or, use imagefilledrectangle() with the same arguments if you want it filled
// Save the image
imagepng($img, "image.png"); // or imagejpeg(), etc.
php imagick! passez le chemin de l'image à une nouvelle instance imagick, dessinez le rectangle, writeImage, done. – markus