ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to create a canvas image in php?

user-image
تم إضافة السؤال من قبل Maalik Muhamed , Deputy Mill Manager , AZANIA GROUP OF COMPANYS
تاريخ النشر: 2014/05/24
Afsheen Atif
من قبل Afsheen Atif

If your question is how to draw a canvas (canvas is a rectangular area on a page)and an image over it in Php then here is a simple example to draw a black  rectangular canvas and a pink rectangle over that canvas:

 

<?php

// Create a200 x200 canvas image

$canvas = imagecreatetruecolor(250,200);

 

// Allocate color for rectangle

$pink = imagecolorallocate($canvas,255,105,180);

 

// Draw rectangle with its color

imagerectangle($canvas,50,50,200,150, $pink);

 

// Output and free from memory

header('Content-Type: image/jpeg');

 

imagejpeg($canvas);

imagedestroy($canvas);

?>

 

Cheers!

Jasim Ahmed
من قبل Jasim Ahmed , Technical and Engineering Lead , alkamilbooking.com

Well there are lots of ways to create Canvases in PHP. There is ImageManipulation Library ann Canvas Class I used once. I do not know what you need actually and why you asked this question so I take it as general knowledge discussion.

Once you have the class you can call it this way to use an Image Canvas:

 

require_once "canvas.php"; // Canvas Class Path

$img = new canvas("image/test.jpg"); // Image to be manipulate

$img->resize("1024", "768") // Resizing Image if needed

    ->filter("grayscale") // FIltering to Grey Scall, web optimized

    ->text("JayZee", array( // Text you want to put on Canvas, text properties

           "color" => "#fff", 

           "background_color" => "#000",

           "size" =>10,

           "x" => "right",

           "y" => "bottom"))

    ->save("temp/new_image.png"); // Saving image to new format, PNG

 

So thats how you do it. And there are many other features in PHP Canvas . I hope thats clear how to use Image Canvas using PHP Canvas.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟