View Full Version : 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 ....
:D
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
Well, still trying to figure it out myself but here’s a couple of links:
http://www.colorum.de/xampp/gd.html
http://www.phpbuilder.com/columns/allan20000830.php3
http://www.php.net/manual/en/function.imagecopyresized.php
http://php.weblogs.com/GD
Hi There
I developed a website that required a lot of image manipulation using php code. I used netpbm. Worked well
Sam
What's netpbm and where can i get it ?
AnonymousReseller
06-04-03, 07:50 AM
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
I also cannot install anything on the server. I need to use the basic features of gd 1.6
From v. 1.6, GD doesnt support GIF manipulation. Check here (http://www.boutell.com/gd/manual1.8.4.html#whatsnew1.8.4)
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
Daniel Bahl
06-06-03, 09:29 AM
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 :D
$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);
?>
Daniel Bahl
06-06-03, 09:30 AM
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);
?>
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/showfiles.php?group_id=7130
ImageMagick is possibly another option
KingSky
06-10-03, 01:23 AM
I was going to suggest netpbm as well... it is not something that you specifically need to install on your server.
netpbm is used in PHPGallery because the authors feel it has far superior quality imagewise to GD. You can read some more about it on the PHPGallery website:
http://gallery.sourceforge.net/
Sorry I don't know the netpbm website offhand.
Netpbm can compiled into seperate module that you can execute in your php scripts.
So therefore no modifications to the server are required.
so you mean i can use it as normal functions ? without having to modify anything on the server etc ?
Ok what you have to do is get hold of the Netpbm source and compile the binaries as stand-alone units. For me this was the most difficult part and I got somebody else to do it for me
The result is that you get a collection of binaries that can manipulate images via command line.
What you then do is run command line commands via php. For example this is a method I wrote to flip an image.
<?php
class Netpbm_Image
{
// Path to Netpbm Binaries
var $netpbm_Root;
// NetPbm Binaries
var $pnmflip;
// Temp JPEG and PNM File names
var $mater_pnm;
var $temp_pnm;
var $temp_jpeg;
function Netpbm_Image()
{
// Path to Netpbm Binaries and Tempary directory for image manipulation
$this->netpbm_Root = "/control/netpbm/bin";
// NetPbm Binaries
$this->pnmflip = $this->netpbm_Root . "/pnmflip";
}
// This function flips and image from left to right
function flip_lr()
{
$command = $this->pnmflip . " -lr "; // NetPbm Command
$command .= $this->temp_pnm; // Source File
$command .= " > " . $this->temp_pnm . ".out"; //output To
exec($command); // Execute Command
}
}
?>
As you can see no modifications are required to the server you can just run the binaries
that i cannot do, not allowed to install software.
You dont; need to install software. you just need the binaries. You then run the files directly
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.