Jump to content

GD Image help


jay83r

Recommended Posts

Hi there, i want to draw dynamic lines by using ImageLine($image, 0, 0, 100, 100, $color) but i want to store the line co-ordinates in a mysql database so i can give each line a meaningful name and call them and display when I want to... anyone with anyideas?

Link to comment
Share on other sites

Seems like you've summed up exactly what you should do.

 

I'm not sure what you've left out?

 

Just keep all the lines in a table, with x1,y1 and x2,y2 columns, along with columns for an id and whatever meta data you need to store.

 

If you need help with the actual code, I suggest posting what you have so far. If you don't even know where to start, I suggest checking out the introduction section of the PHP manual.

Link to comment
Share on other sites

i've got this but i'm totally lost with it, i'm getting a header issue, and im not sure how to to do the mysql part.

<?php

$image = ImageCreate(200, 50);

$background_color = ImageColorAllocate($image, 255, 255, 255); // white

$gray            = ImageColorAllocate($image, 204, 204, 204); // gray

 

ImageFilledRectangle($image, 50, 10, 150, 40, $gray);

$image = ImageCreate(200, 50);

$background_color = ImageColorAllocate($image, 255, 255, 255); // white

$gray            = ImageColorAllocate($image, 204, 204, 204); // gray

 

ImageFilledRectangle($image, 50, 10, 150, 40, $gray);

 

header('Content-type: image/png');

 

ImagePNG($image);

 

 

  ?>

 

Link to comment
Share on other sites

i've fixed the header issue, and are able to draw a line with text, but how to i reference this to a table in a database

 

<?php

// set the HTTP header type to PNG

header("Content-type: image/png"); ?>

<?php

 

header ("Content-type: image/png");

$handle = ImageCreate (640, 480) or die ("Cannot Create image");

$bg_color = ImageColorAllocate ($handle, 255, 255, 255);

$txt_color = ImageColorAllocate ($handle, 0, 0, 0);

$line_color = ImageColorAllocate ($handle, 0, 0, 0);

ImageLine($handle, 0, 0, 200, 0, $line_color);

ImageString ($handle, 8, 5, 18, "base line", $txt_color);

ImagePng ($handle);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.