r3d
Oct 24 2004, 12:52 PM
With php gd is the image function library of php. The functions include in this library enable php users to creating image up to manipulating photos. PHP gd can create with file extension of jpg, gif, swf, tiff and jpeg2000. Installation see http://www.php.net/manual/en/ref.image.php. Astahost hosting service has enable gd library, so won’t need any extra works except in coding. Lets get started, creating images from php set the canvas: CODE $img = imagecreate(250, 80)
imagecreatethis function create and set a blank canvas with the wide of 250 pixels and height of 80 pixels. setting the basic colors: CODE $black = imagecolorallocate($img, 0, 0, 0) $white = imagecolorallocate($img, 255, 255, 255) $red = imagecolorallocate($img, 255, 0, 0) $green = imagecolorallocate($img, 0, 0, 255)
imagecolorallocate $img represent the canvas. the next three value is color value in rgb(0-255), you also set the color in hex (0x00 – 0xff). drawing a something: CODE imagerectangle($img, 10, 10, 240, 70, $white)
imagerectangle this function create a rectangle a width of 230[240(x2) – 10(x1)] and a height of 60[70(y2) – 10(y1)]. $img the canvas, the first two value sets the starting point(x1, y1) . and last two number is the ending(x2, y2). And the last value is the color. CODE imagefilledrectangle($img, 20, 20, 60, 60, $red)
imagefilledrectangle this function create a filled rectangle with a color red. All values is the same as the imagerectangle function. CODE imagefilledellipse($img, 90, 40, 40, 40, $blue)
imagefilledellipse this one creates an ellipse(circular objects). $img is the canvas, the first two value(cx, cy) set the origin(center) of the ellipse. The third value set the width(horizontal width) and fifth one is the height(vertical width). Last but not the least the color value. CODE $corners = array( 0 => 190, 1 => 60, 2 => 210, 3 => 20, 4 => 230, 5 => 60, ); imagefilledpolygon($img, $corners, 3, $white);
imagefilledellipse and the last drawing function I discuss is a polygon function, in the example there’s only 3 corners. The first value is the canvas, the second one is the corners in array, the value 3 is the number of vertices, and the last one is color. Showing the graphics: CODE header("Content-type: image/jpeg") imagejpeg($img)
header imagejpeg To output the image you must first send the appropriate header, in this example I use jpg extension and the content type is set to “image/jpeg”. And call the imagejpeg function to create the images and shown up to the browser. For other file type such as png(image/png), gif(image/gif), windows bitmap(image/vnd.wap.wbmp), check php manual for details. And finally, use the imagedestroy function just to clear up the memory used by the imagecreate functions. Final code should look like this. CODE <?php
$img = imagecreate(250,80);
$black = imagecolorallocate($img, 0, 0, 0); $white = imagecolorallocate($img, 255, 255, 255); $red = imagecolorallocate($img, 255, 0, 0); $green = imagecolorallocate($img, 0, 255, 0); $blue = imagecolorallocate($img, 0, 0, 255);
$corners = array( 0 => 190, 1 => 60, 2 => 210, 3 => 20, 4 => 230, 5 => 60, );
imagerectangle($img, 10, 10, 240, 70, $white); imagefilledrectangle($img, 20, 20, 60, 60, $red); imagefilledellipse($img, 90, 40, 40, 40, $blue); imagefilledellipse($img, 150, 40, 70, 40, $green); imagefilledpolygon($img, $corners, 3, $white);
header ("Content-type: image/jpeg"); imagejpeg($img); imagedestroy($img); ?>
enjoy
Reply
squirel
Oct 24 2004, 02:43 PM
Very nice tutorial, well written and very descriptive. I had no clue you could do this with php. I guess you learn something new every day. Time to go play with this stuff.
Reply
marijnnn
Oct 24 2004, 04:04 PM
well, to give you an idea what you could use this for: thumbnails i'm a lazy kid so i upload my pictures with ftp then some guy/girl visits my site and my picture page he opens the directory with the new pictures the script checks all the pictures and checks if they all have a thumbnail (if a filed is called blabla.jpg, the thumb is called .blabla.jpg, so it's invisible too) if there isn't, i make one with gd!!! it's great. i never have to make pages anymore, never make thumbs,... gd rocks quite a lot!
Reply
marijnnn
Oct 24 2004, 04:28 PM
hm, apearently it's not working atm. it worked before, but today it's all fucked up. php says it doesn't know the function imagecreatefromjpeg... help!
Reply
neno.tu
Oct 24 2004, 04:43 PM
Maybe the GD library is not enabled... Wait for tomorrow and see what happends... By the way... I made a picture gallery with PHP+GD... If anyone would like to I can make a tutorial to create thumbnails and stuff... Also an advice: Don't use: CODE imagecreate($width,$height) That could make your pictures look preaty bad... Use: CODE imagecreatetruecolor($width,$height) That makes it look exactly like is and you won't lose the image quality... If you can't use the GD library you could use ImageMagic too.. is a library that can do the same and more... Hope it helps...
Reply
marijnnn
Oct 24 2004, 05:15 PM
yeah, but all the extensions are disabled atm gd, exif,... i am using truecolor, don't worry  it works fine on my own computer, but it's not working with astahost. but i've heard/read that they are having problems, so i'll just wait till those are solved...
Reply
r3d
Oct 25 2004, 04:43 AM
outch astahost hosting has no gd support for the moment, may be... this is part of the problem . and the tutorial won't work at this time. plz be patient while the admin is fixing this
Reply
avalon
Oct 28 2004, 07:17 PM
QUOTE(r3d @ Oct 24 2004, 08:52 PM) Final code should look like this. CODE <?php
$img = imagecreate(250,80);
$black = imagecolorallocate($img, 0, 0, 0); $white = imagecolorallocate($img, 255, 255, 255); $red = imagecolorallocate($img, 255, 0, 0); $green = imagecolorallocate($img, 0, 255, 0); $blue = imagecolorallocate($img, 0, 0, 255);
$corners = array( 0 => 190, 1 => 60, 2 => 210, 3 => 20, 4 => 230, 5 => 60, );
imagerectangle($img, 10, 10, 240, 70, $white); imagefilledrectangle($img, 20, 20, 60, 60, $red); imagefilledellipse($img, 90, 40, 40, 40, $blue); imagefilledellipse($img, 150, 40, 70, 40, $green); imagefilledpolygon($img, $corners, 3, $white);
header ("Content-type: image/jpeg"); imagejpeg($img); imagedestroy($img); ?>
enjoy  Is there a way to save it somewhere on the server as a jpg, gif or png with a filename before imagedestroy($img)?
Reply
avalon
Oct 28 2004, 07:20 PM
QUOTE(r3d @ Oct 25 2004, 12:43 PM) outch astahost hosting has no gd support for the moment, may be... this is part of the problem . and the tutorial won't work at this time. plz be patient while the admin is fixing this  Can we request for it to be installed. gd and magick is fabulous for auto image generation. Freetype is oftenly required too, you will be happy to find out what it can do.
Reply
r3d
Oct 28 2004, 07:33 PM
please don't double post, use the edit button  about the gd it's allready installed. and about your first question no, it must be save as php or it will not be parse, just a suggestion u can do something like this image.php?id=image_name with the gd
Reply
Latest Entries
ml01172
Oct 8 2008, 03:28 PM
QUOTE(vladimir @ Dec 28 2004, 04:29 AM)  What is actually the path for GD graphics library? I need it for my coppermine galery.
I would like to upload it manually because I'm using my own database...but I don't know the path for the GD. I have a backup of the mysql database I already used on a different server. It works fine, but just the thumbnails are not displayed.
Maybe somebody knows how to install/use GD for a coppermine picture galery? Thanks in advance for your help. GD library isn't related to any of the user-libraries and scripts, like coppermine gallery etc., but strictly to PHP. You have to install or upgrade your PHP at the server so it contains GD. Try doing this, for an example. Download PHP source from PHP.NET (try getting the version you already have installed) and, if you're on Linux, do the following: 1. Unpack the PHP package you got 2. Change directory into the created PHP directory. 3. Type: ./configure --with-gd 4. If configuration successfull, type: make (not "make install", and not necessarily as root) Once compilation process is over, look into the "modules" directory. A library with .so extension should be there so just copy it into your local "modules" directory for PHP (usually /usr/lib/php/modules or similar). Restart your web server. Cheers
Reply
iGuest
Aug 19 2008, 11:28 AM
How to call the image into other PHP page?
Basic Tutorial: PHP GD
Ok, I've done create a chart using GD.. And then I want to call that chart into my php page let say data.Php.. Then how to do that? I've tried using include function and even < img > tag but it just not work.. -question by ableze_joepardy
Reply
vladimir
Dec 28 2004, 02:29 AM
What is actually the path for GD graphics library? I need it for my coppermine galery. I would like to upload it manually because I'm using my own database...but I don't know the path for the GD. I have a backup of the mysql database I already used on a different server. It works fine, but just the thumbnails are not displayed. Maybe somebody knows how to install/use GD for a coppermine picture galery? Thanks in advance for your help.
Reply
thedevil
Nov 21 2004, 08:55 AM
QUOTE(marijnnn @ Nov 19 2004, 04:12 PM) ok, a short sum up on some of the question. saving as a jpeg: he tried but forgot the filename  imagejpeg ( $img, test.jpg , 78); that'll do the trick 2. gd is installed on astahost. no problem. you can use it as you wish 3. installing gd on your own pc. i guess you are using a windows machine as you mentioned dll. well, you have the dll, it's packed with php. what you need to do is find the lines that say which extensions to use. unquote the extension that says gd.dll or gd2.dll (you can do this by removing the ; in front of the line) restart your iis or apache server. done! Thanks I will Try that...
Reply
r3d
Nov 19 2004, 07:05 PM
php 4.9+ use gd2 which is bundled in the installation by default. but not enable by default. read marijnn's post and put the gd2.dll in windows folder also some dll is required like icon.dll you should put this dll in window folder too
Reply
Recent Queries:--
php simple gd example - 3.34 hr back. (1)
-
gd php tutorial - 6.79 hr back. (1)
-
php gd tuto - 9.83 hr back. (1)
-
gd library tutorial - 11.01 hr back. (1)
-
gd tutorial - 0.68 hr back. (2)
-
gd php example - 1.00 hr back. (2)
-
php gd vector - 17.49 hr back. (1)
-
tutorial gd library - 19.85 hr back. (1)
-
php gd progress bar - 21.38 hr back. (1)
-
php gd tutorial - 2.69 hr back. (6)
-
gd php import vector graphics - 24.93 hr back. (1)
-
php gd library tutorial - 28.54 hr back. (1)
-
php gd text example - 33.70 hr back. (1)
-
tutorial gd - 34.24 hr back. (1)
Similar Topics
Keywords : php, gd, basic, tuts
- Basic C++ Coding
(9)
Basic C Language, Functions
(5) In a complicated and/or big C programs, a programmer might need to use the same peice of code more
than one time. However repeating the code can be both time consuming and frustrating. Thats why we
use functions. Definition: A function is a small subprogram having its own name and datatype. It
is used to carry out certain operations more than one time without the need of repetition. One of
the functions we all know is the main functions; void main(). I will explain the void later.
Syntax: Each function is composed of 3 parts: Name of the function Info type of the....
Linux Partitioning Guide (new Users)
A very basic guide to partitioning in linux designed for new users (1) QUOTE Partitioning Guide This guide is designed for users New to Linux. 1. All Linux users
run as just that 'a user'. If you are moving from Windows it is most likely that you ran
Windows as an 'Administrator' (root). In Linux, any task which alters the Operating System
(OS) of a Linux distro requires 'root' privileges. You will need the 'root' password
to do this. Basically, this gives you temporary access to the core of your OS. This is what makes
Linux far more secure than Windows. 1. That being said you will now understan....
Basic Html Tutorial
Made it myself, hope you like it. (1) HTML stands for hyper text markup language. It is a basic coding language used on almost every
website. There are some tags in HTML which must be used, whilst others are enhancing, but not
essential. Below I shall list the essential tags and there uses: This tells the browser that
the language between the tags is going to be HTML so it knows how to read it. Inbetween those tags
come These tags tell the browser that all the content that you wish to be displayed is in there.
They are the only essential tags for HTML! The list is short but if you only use them your ....
An Absolute Basic Guide To Algorithms For Dummies
(0) I really want to learn about algorithms but i dont know how it works at all. Can anyone suggest a
site, or more preferably a book that can introduce me to algorithms?....
Basic Css
(6) can someone help me learn CSS or give me a good link to learn it....
Linux Basic Command - For Storing Compilation Error To File
(1) Ex: Compiling a cpp file using a basic command " g++ filename.cpp " and to run the program use
./a.out , Then to store the compilation error to text file use this command. g++ test.cpp >
log.txt log.txt contains the compile time errors. ....
Some Usefull Linux Basic Commands And Utilities. Please Add To This List If You Know One.
(0) Let me give some usefull linux commands and utilities. Please add to this list if you know.
Work with tar files. To make tar archive use $ tar -cvf filename.tar filename
To extract tar archive use $ tar -xvf filename.tar To extract tar archive
with gz use $ tar -xzvf filename.tar.gz Connect to remote system through ssh
$ ssh name@ip followed by passwd e.g. ssh project@172.16.0.14 passwd: List the
file in current directory $ ls -l list the running process ....
Lesson1 :introduction To Visual Basic
(2) QUOTE Hi, Friends, Welcome to Visual Basic tutorial! You have come to the right place to
learn Visual Basic Programming. I like to share the knowledge with you because I have intense
passion on Visual Basic. I wish you could spend some time reading the tutorial so that you can
really acquire the basic skills in Visual Basic programming. Happy Learning! 1.1 What is computer
programming? Before we begin, let us understand some basic concepts of programming. According to
Webopedia, a computer program is an organized list of instructions that, when executed, causes....
Basic Forensics: Winhex
Reading sectors on a mounted disk/storage volume (1) WinHex is a hexadecimal editor that allows you to read sectors on a mounted volume with support for
FAT, NTFS, Ext2/3, ReiserFS, Reiser4, UFS, CDFS, UDF file systems. The basic program is available
free for download, although there are levels of licenses that can be obtained for to unlock
additional features. These include their individual licenses Personal ($56.00), Professional
($105.00), Specialist ($255.00) and X-Ways Forensics ($929.00) which cover the cost for one (1)
license of its type. In the world of IT, a tool like WinHex comes in quite handy when working wit....
Drawing Basic Rectangles
Using Java! (0) I posted on another forums... But not allowed to post links /wink.gif"
style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> In this tut ill show you how
to draw two basic rectangles with Java. First we start with out imports: CODE import
java.awt.*; import java.applet.Applet;//tells the browser its an applet lol Now we start with the
class: CODE public class Rectangles extends Applet { And then the voids: CODE
public void paint(Graphics g) //you will always need Graphics g so the applet knows its a drawing
{ ....
Basic Setup For Apache In Solaris 10
An step by step guide to configure an Apache web server in Solaris 10 (1) HOW TO SETUP APACHE SERVER IN SOLARIS 10 Apache Web Server is already included and installed in
Solaris 10 (Update 08/07). Normally it is already running as a service, but it requires some
configuration to make it run as you desire. I will use the '#' to indicate the commands
you should execute as root, and '%' to indicate it is a command to run as user. 1. Stop
the web server # svcadm disable svc:/network/http:apache2 2. Copy the file
/etc/apache2/httpd.conf-example to /etc/apache2/httpd.conf. The file 'httpd.conf-example'
contains an e....
Html Basic Tutorial
<!-- For beginners only --> (9) Knowledge HTML stands for H yper T ext M arkup L anguage. You cannot create an HTML file
using a rich-text editor, such as Microsoft Word or Wordpad. HTML To write a basic HTML, you will
need to start with this: CODE The html > tag tells the browser that this is an HTML page.
To close any tag, the same tag will be repeted but with the "/" sign. For example, CODE
Page title Did you notice the /title >, /head > & /html > tags? That's how we
close the tag. The HEAD > Tag A head > tag will include the meta >, titl....
Installed Internet Explorer 7?, Visual Basic Now Broken?
(3) This quick guide shows you how to fix this error. Step 1): Go to your control list by right
clicking the toolbar underneat the default controls and clicking "Components" or by Pressing "CTRL +
T". Step 2): In the Components Box that pops up scroll down to "Microsoft Internet Controls",
click on it once so that it becomes highlighted. Now look at its "Location" it will say either
"C:\Windows\System32\ieframe.dll" or "C:\Windows\System32\ieframe.dll\1". Step 3): Now you need to
browse for the correct file, so with the "Microsoft Internet Control" still highlighted cli....
Phpbb - Installation Tutorial ( For Newbies Based On Astahost Cpane)l
phpBB 2.0.22 installation Tutorial with basic steps. (5) Introduction!! Providing a comprehensive 'How To' tutorial guide, on the
installation of phpbb 2.0.22 forum on your Astahost/cPanel account. Tutorial includes Downloading
of files Uploading using cPanel File Manager CHMOD using cPanel File Manager MySQL database
creation PhpBB initial configuration This guid will help everyone from beginners, with images and
an in depth guide of what to do. Step 1 To start with we need to download PhpBB ( latest stable
version is PhpBB 2.0.22 ). This can be done by visiting the PhpBB Downloads page which shou....
Asterisknow Pbx (voip Telephony)
A basic run down & some questions (1) I was wondering if anyone here ever used (or uses) Asterisk? If you don't know what Asterisk is,
it is a VoIP server (Voice over IP). Basically, it's like Vonage's servers in your home
(beats the $24.99 month phone bill from Vonage, plus your local phone bill, plus internet bill).
Anyways, nothing beats a POTS right? Well, features such as Voicemail, call forwarding, voice
options (menus), etc can come with a price tag from your phone company. You already have copper
phone lines coming into your house so why should you pay extra for these services when you ca....
C++: Basic Classes
classes, objects, access labels, members, inline functions (5) This tutorial assumes that you have a basic knowledge of C++. You know how to use built-in types,
like ints, doubles, chars, etc. You should know some types that are part of the STL, like vector,
etc. Those types that come in the STL are just C++; you can create your own types just like those!
Non built-in types are referred to as classes . To create a class, you just use the keyword class
, the name of the class, and curly brackets. CODE //A class named MyClass class MyClass { };
In fact, that is all we need to create variables, pointers, or references to t....
Hamachi - Your Next Best Friend
A basic introduction to hamachi (2) Hamachi is probably one of the best tools in the world. So, being the best tool in the world, i
thought i'd share it with you guys Introduction: What is hamachi? Hamachi is a versitile
tool, that "organize two or more computers with an Internet connection into their own virtual
network for direct secure communication". What this means is basicly you can set up and LAN
connection between you and anybody else in the world as long as you both have hamachi. Have a
firewall or modem? No problem, Hamachi compensates! Quote from the Hamachi website: "Think - LAN
over ....
Visual Basic.NET Help Needed.
(8) I have a project to submit this wednesday, and i have to make it a working program. Not a big one ..
but just sumthing small that includes : Splitter, Progress Bar & Track Bar. I thought of making
sumthing like the picture below, I would enter the text and hit the button .. the text would come in
BOTH the labels. Then i move the track bar on the left to increase the font or/and the track bar on
the right to change the color ( RBG only 3 colors ). The progress bar at the bottom will show the
progress every time i move either of the track bars to a level. Nothing fanc....
Finding The Current Line Number In A Text Box
A very basic method of doing the deed. (1) Language: Visual Basic 6.0 (5.0/4.0) Level: Beginner Problem: How to find the current Line Number
in a multiline text box? Some times it is necessary for us to provide a text editor in our
programs, or maybe a text viewer. The text box control has no built in method to find the current
line number like RichTextBox. Hence we need to code it manually. Solution: The simple concept of
line numbers is the carriage return character, or simply the ASCII code 10. The line feed character
has the ASCII code 13. In the code example I have used chr(10), you can also use vbCrLf i....
Performing Dos Operations From Visual Basic
The easiest and most powerful way to do (1) Performing DOS Operations from Visual Basic By: Abhishek Chatterjee Language: Visual Basic
6.0 and below Difficulty: Beginner Does your project need to perform some DOS based or Command
line operations? Although there are many techniques to do the same, but performing tasks like
calling the DIR DOS command to list the contents of the directory or calling the Move command to
move a folder, and the like, can't be done as smoothly by the built in functions of VB or the
Windows API. The technique that I introduce to you is extremely simple, doesn't req....
Visual Basic 6 + Crystal Reports 9
how to distribute (6) I have made a software with Visual Basic 6 and Crystal Reprots 9. Now I have to distribute it on the
client side but the problem is coming in distributing the Crystal Reports. I have tried Setup
Factory but it is not working. Then I have used Visual Studio Installer from Microsoft and
downloaded Crystal Report Merge Modules from Business Objects website. It is working properly but
now the setup file size is very big because it carries a lot of files with it. Is there any other
installer software which can automatically select the required files to be distribute with the ....
Making A Nice Looking Signature In Photoshop Cs
Some basic Photoshop skills required... (17) Here's a guide you can use to help you make a signature image in Photoshop CS. Before we begin
you need to pick out a good "render" for your signature. A render is basically an image that takes
the focus in your signature, the render I will use currently looks like this First off I hit
Ctrl+A and then Ctrl+C, then I go to File> New, and I set my image proportions to 410 wide, and 165
high. Then I hit Ctrl+V and right click the eraser tool I select the Magic eraser tool, I hold down
Ctrl and then left click my render. I move my render all the way to the right, th....
Visual Basic: Random Strings!
(10) This article will teach you how to get random strings for output to a label caption, or anywhere you
want it to go. 1. First we need to declare our string names: CODE Private RndString(2)
This declaration says there will be an array of strings called RndString, and there will be 2
strings in that array. 2. Then, we need to create a function that will generate a random number.
CODE Private Function RandomNumber(rUpper As Integer, Optional rLower As Integer) As Integer
' Generate random number between upper and lower bound values Randomize R....
Visual Basic: Unload Your Application Correctly!
(1) What many of us do not know is that using a button on a form with the function "Unload Form1" or
even clicking the X in the upper right corner is like pulling the plug out of your computer while it
is still on. It may not exit the program cleanly and efficiently, may leave background processes
running, or just give you unwanted errors by exiting improperly. All you need to do is unload all
components, forms, controls, etc. upon unloading. Say you have 2 forms in your project, 1
component, and 2 controls. If these ojects are placed onto a form, unload them properly!....
Visual Basic: Replace Explained!
(4) This tutorial will go over how to effectively use the Replace function in Visual Basic. 1. So
you have a string. Whether it be a label caption, an entry in a text box by the user of your
program, or an item in a combo box. Let's say this is a bad string, something you do not want
to appear. For instance, a user types "X is gay" in a text box, and you want to change that to
something else. You can simply have it be deleted, or replaced with another value. 2. To make
this work when a user types something in a textbox, you will need to use this sub: CODE ....
Visual Basic Help
need help useing visual basic (7) i was just wondering, when you are useing the program Visual Basic is there any way to add some
animation to a form, and if so what is a good(cheep) animation program i could get?....
Basic C++ Language
Getting started with C++ (19) You will need passion , devotion and even obsession to really appreciate C++ Programming.
Lets grab a compiler If you have a C++ Compiler then you are all set for turning your C++ code
into executable files, if you do not then I recommend getting dev-c++ . To learn more about that
compiler I recommend browsing their site. First Program - number.cpp So now I'm going to
write up our first program to learn from, which shows how we can display text to the screen. I know
it's probably a bit simple, so maybe I'll spruce it up a bit, as no matter h....
Basic css code
(2) to create a website in css...you will need to start with the basic code... /* CSS Document */....
Basic Tips and Tricks in HTML
(15) Here is some quick links for basic html coding... A quick and easy way to create your first web
page! -> The easiest HTML guide for beginners You'll learn how to create tables from real
examples. -> How to create TABLE? You will learn how to create frames from a real example.
You'll see how to create a borderless frame, how to specify the target frame, etc. -> How to
build FRAMES? Follow a few easy steps to add sound to your web pages. -> How to add sound to a
web page? This page tells you how to automatically load a visitor to another web page.....
Looking for php, gd, basic, tuts
|
*SIMILAR VIDEOS*
Searching Video's for php, gd, basic, tuts
|
advertisement
|
|