Current location: Hot Scripts Forums » Programming Languages » PHP » Image Editing With GD


Image Editing With GD

Reply
  #1 (permalink)  
Old 06-03-03, 05:20 PM
Damian's Avatar
Damian Damian is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Image Editing With GD

Hello, (Clear Throat)

I'm very touched to be the one opening this forum. It all started on...bla bla bla ....




Anywayz.... Ok here goes the real reason of my post. I cannot install gd 2.0... so to make that clear from the very begginning. Let's say i want to edit a jpg, gif or png image with an image editor made with php...very basic...resize image, place text on the image (maybe antialias text), insert another picture over this picture (idea behind this is to have a website title and then maybe one can insert a logo or picture in it or anything).... Any ideas, help, ready-made scripts...whatever...

Thanks
Damian
Reply With Quote
  #2 (permalink)  
Old 06-03-03, 05:30 PM
A.B.'s Avatar
A.B. A.B. is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Cairo, Egypt
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
__________________
A.B.
Reply With Quote
  #3 (permalink)  
Old 06-04-03, 05:11 AM
sam sam is offline
New Member
 
Join Date: Jun 2003
Location: South Africa
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hi There

I developed a website that required a lot of image manipulation using php code. I used netpbm. Worked well

Sam
Reply With Quote
  #4 (permalink)  
Old 06-04-03, 05:59 AM
Damian's Avatar
Damian Damian is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
What's netpbm and where can i get it ?
__________________
"My occupation now, I suppose, is jail inmate."
- Unibomber Theodore Kaczynski, when asked in court what his current profession was.
Reply With Quote
  #5 (permalink)  
Old 06-04-03, 06:50 AM
AnonymousReseller AnonymousReseller is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Netpbm is a toolkit for manipulation of graphic images, including
conversion of images between a variety of different formats. There
are over 220 separate tools in the package including converters for
about 100 graphics formats.

You can get it: http://netpbm.sourceforge.net
Reply With Quote
  #6 (permalink)  
Old 06-04-03, 07:26 AM
Damian's Avatar
Damian Damian is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
I also cannot install anything on the server. I need to use the basic features of gd 1.6
__________________
"My occupation now, I suppose, is jail inmate."
- Unibomber Theodore Kaczynski, when asked in court what his current profession was.
Reply With Quote
  #7 (permalink)  
Old 06-04-03, 11:14 AM
phpkid phpkid is offline
Hot Moderator ;)
 
Join Date: Jun 2003
Location: India
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
From v. 1.6, GD doesnt support GIF manipulation. Check here

For rest of the stuff what you want to do, links provided by A.B. should give you almost all the info you need!

Regards,
JD
__________________
http://www.phpkid.org
Reply With Quote
  #8 (permalink)  
Old 06-06-03, 08:29 AM
Daniel Bahl's Avatar
Daniel Bahl Daniel Bahl is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Denmark (City: Haslev)
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Damian

First of all, with 1.6, you can't use GIF, but JPEG and PNG is still avaible!

Just some basic GD steps:

1.
load picture

<?php
$im = ImageCreateFromJpeg("$DOCUMENT_ROOT/path/to/picture/knap.jpg");
?>

2. write text on picture

<?php
$black = ImageColorAllocate($im,0,0,0);
ImageTTFText ($im,10,0,5,15,$black,"font.ttf","some text");
?>

$sort = ImageColorAllocate($im,red,green,blue);
if red, and green and blue = 0 - it means black

$im = remember the $im, is the picture we opened before

ImageTTFText ($im,10,0,5,15,$sort,"font.ttf","Menupunkt");

remember the first number (10) is the font-size, the next number is the degree of the text, and the last two numbers are the cordinates of the text


Final (to make a complete example):

<?php
$im = ImageCreateFromJpeg("$DOCUMENT_ROOT/tuts/gdlib/knap.jpg");
$sort = ImageColorAllocate($im,0,0,0);
ImageTTFText ($im,10,0,5,15,$sort,"arial.ttf","Menupunkt");
header("Content-type: image/jpeg"); // image/png if it is a png picture
ImageJPEG($im); // or ImagePNG if it is PNG
ImageDestroy($im);
?>
__________________
Why don't share your knowledge?!
Reply With Quote
  #9 (permalink)  
Old 06-06-03, 08:30 AM
Daniel Bahl's Avatar
Daniel Bahl Daniel Bahl is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Denmark (City: Haslev)
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Also look here:
http://dk.php.net/manual/en/function.imagecreate.php

<?php
header ("Content-type: image/png");
$im = @imagecreate (50, 100)
or die ("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng ($im);
?>
__________________
Why don't share your knowledge?!
Reply With Quote
  #10 (permalink)  
Old 06-08-03, 04:31 PM
Perry Perry is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Tennessee
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
I used to be on a server without GD 2 and I used NetPBM with some success. I was only resizing images, no overlays. You don't have to "install" NetPBM on the server, there are precompiled binaries here

http://sourceforge.net/project/showf...?group_id=7130

ImageMagick is possibly another option
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gd 2 - Rgb Image -> Grayscale Image mlspacy PHP 2 06-10-09 04:13 PM
dynamic image src = Newbie question clintre PHP 1 10-07-03 09:56 AM
camera phone image poster apt2 Script Requests 2 08-29-03 07:20 PM
A different kind of image counter Stix Script Requests 1 08-11-03 11:50 PM
Skript to convert email to image spade PHP 1 06-11-03 09:28 AM


All times are GMT -5. The time now is 06:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.