Working With Images

Started on the old forum in June 2006 · view the original in the archive · old links redirect here

8 replies · 1,687 views · started 20 years ago · 1 min read

4 participants
CLINT #1

Ok, I am really getting into creating images from php. I want to make a script where by people can create their own 'designer wallpaper'.

Here is a simple script that will let you use fonts in your text.

<?php
  Header("Content-type: image/gif");
  if(!isset($s)) $s=11;
  $size = imagettfbbox($s,0,"/$font",$text);
  $dx = abs($size[2]-$size[0]);
  $dy = abs($size[5]-$size[3]);
  $xpad=15;
  $ypad=15;
  $im =imagecreate($dx+$xpad,$dy+$ypad);
  $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); //background
  $black = ImageColorAllocate($im, 0,0,0);//outline
  $white = ImageColorAllocate($im, 255,255,255); //text colour
  ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
  ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
  ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "/$font", $text);
  ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "/$font", $text);
  ImageGif($im);
  ImageDestroy($im);
?>

Just add some fonts in the same DIR as this script. Now link to ThisFile.php?text=SomeText&font=Somefont.ttf

But how do we add a picture into this script? So that we can edit some picture.gif to make our wallpaper.

naveen-PHP LEARNER #2

Nice question.... External image (may be gone) You can use GD functions...

To edit a GIF image , use imagecreatefromGIF(filename); function. To edit a JPEG image , use imagecreatefromJPEG(filename); function. To edit a PNG image , use imagecreatefromPNG(filename); function. To edit a WBMP image , use imagecreatefromWBMP(filename); function. To edit a GIF image , use imagecreatefromgif(filename); function.

You can also find an image from a string and edit it with,

imagecreatefromSTRING(stringvar);

.

Also , Good-Luck External image (may be gone)k: for your imagecreating script. Hope you share it with us. External image (may be gone)

stretch Developer · 130 posts #3

imagecreatefromjpeg(PHP 3>= 3.0.16, PHP 4 >= 4.0.0) Create a new image from file or URL resource imagecreatefromjpeg ( string filename) \linebreak imagecreatefromjpeg() returns an image identifier representing the image obtained from the given filename. imagecreatefromjpeg() returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser. To ease debugging the following example will produce an error JPEG: Example 1. Example to handle an error during creation (courtesy vic@zymsys.com )

function LoadJpeg ($imgname) {
$im = @imagecreatefromjpeg ($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate (150, 30); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}

= = = = = The more you laugh...the longer you live. Read more jokes at http://fun-files.co.cc

subzero Super moderator Fellow · 3,954 posts #4

http://topsite.6te.net/always.wml

a test bro not sure how to make that soon work on it

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close