Re: AW: [PHP] image function

2002-08-13 Thread Nicholas Mercier

At 03:37 AM 8/13/2002 +0200, you wrote:
Hey there,

I created a set of scripts that did basically what you are looking to do.

1.   You may have a problem if you uncommented both DLL files.  Apache will 
complain when it tries to load two libraries with the same functions in them.

2.Make sure that the dll file is in the correct place.  It should match 
the extension directory listed in your php.ini file.

3.Additionally you may want to copy the DLL to your WINNT/SYSTEM 
directory (don't know why, but I've been told this helps.)

4.Stop and restart Apache

5. When uploading an image to be resized realize that the data may type 
image/pjpeg (progressive jpeg) and not image/jpeg (This caused my scripts 
to choke on me when checking image types for filtering purposes)

If PHP 4.2.2 doesn't support Jpeg then that is odd since I'm working with 
version 4.1.1 and I have no problems with my image scripts.

Feel free to reply if you'd like to show me your scripts or ask for 
additional clarification.



I got the same Problem right yet. I´m using an create thumbnail library on
my website, but the class don't work on my computer and either not on my
webspace where i tested it too.

On my Computer there is installed Win2K with apache 2.0.35 and PHP 4.2.2. I
used both GDLibs wich came along with my PHP Package, but they both didn't
have support for Jpeg Images.

I'm running ill while I work on this shit. 'Cause I need to create to create
Thumbs from very large images, they're about 2.5 MB each. And right yet I
don't know some about performance and if it will work ever. Later the hole
site will run on an dedicated Linux machine. But I'm not the super pro on
installing and compiling packages on a linux systems. And it would be nice
if i could test the scripts on my WinNT 5 machine.

Please tell me what you found out yet! - I got a very nice image creation
library, wich is under GPL. I'm going to send it soon to ya if you want it.



-Ursprüngliche Nachricht-
Von: NoWhErEMan [mailto:[EMAIL PROTECTED]]
Gesendet: Montag, 12. August 2002 15:50
Betreff: Re: [PHP] image function

Thank you Jay, Yup my apache is on Windows : )
Let's me try first.
Jay Blanchard [EMAIL PROTECTED] ¼¶¼g©ó¶l¥ó·s»D
:002301c24201$b28caf00$[EMAIL PROTECTED]
  I known i need to install a lot of staffs to get all the functions
  Lib, FreeType Lib, libjpeg, libpng, zlibetc etc).
  But i only need a few of them, so if i just load the php_gd.dll, what
  functions included?? I canr found any information about that.
  And one more, does php_gd2.dll also a GD lib?
  The DLL is a Windows library AFAIR, and contains the GD functions when
  included on a Windows server. You do not have to enable this extension on
  Apache server (unless it is Apache on Windows). You just have to make sure
  that PHP is compiled with all of the proper libraries for your use of GD.
  As for the second DLL, I am not sure. I haven't done a lot of Windows GD
  installations, it does not look familiar.

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Re: AW: [PHP] image function

2002-08-13 Thread Nicholas Mercier

At 04:52 PM 8/13/2002 +0200, Sascha Braun wrote:
Okay... I've looked at that library and felt as if I was looking into the 
ark of the Covenant.

I'm really not that good at programing and looking at that script made my 
eyes bleed.

This is a script I've used to save an image and then dynamically resize it 
proportionately until it is within 200x180.  It also renames the file and 
creates a mysql database entry for the file so my image collection can 
later be searched.

//Query Database to get the next sequential image number
$lastnumQry = SELECT imageID FROM images ORDER BY imageID DESC;
$lastnumRslt = mysql_query($lastnumQry, $conn);
$lastnum = mysql_fetch_array($lastnumRslt);
$newnum = $lastnum['imageID']+1;

//Set image directory root
$image_root = $DOCUMENT_ROOT.'/images/';

//Create a temp image file from uploaded jpeg
$tempimage = imagecreatefromjpeg($f_image);

//Get dimensions of image
$temp_h = ImageSY($tempimage);
$temp_w = ImageSX($tempimage);

//Checks that the image is not too small (less than 50x50)

if($temp_h  50  $temp_w 50)
 echo ERROR: Image is less then 50x50.;
//set file name
$filename = $newnum.'.jpg';

//save image
if(!ImageJpeg($tempimage, $image_root.$filename))
 echo ERROR: Image unable to save file.  Try again later.;
//set file name for thumbnail
$smallfilename = $newnum.'_t.jpg';

//Check to see if the image is already within the 200x180 range
if($temp_h  200  $temp_w 180)
 //Save thumbnail
 if(!ImageJpeg($tempimage, $image_root.$smallfilename))
 echo ERROR: Thumbnail Image unable to upload!;

 This section of the script uses the math that to resize an image 
in proportion
 You must cross multiply the dimensions with their ratios... I use 
1.8 and 2.0
 but I could of as easily used 180 and 200.  The math works, I 
don't know how
 to really explain it, but it works.

 echo Resize beginning.BR;
 if(($temp_h*1.8)  ($temp_w*2))
 $ratio = $temp_w/$temp_h;
 $dest_w = 200*$ratio;
 $dest_h = 200;
 if(($temp_h*1.8)  ($temp_w*2))
 $ratio = $temp_h/$temp_w;
 echo Ratio - $ratio br;
 $dest_w = 180;
 $dest_h = 180*$ratio;
 //On the off chance that the image is proportionate to 200x180 
already we just set the height and width.
 if(($temp_h*1.8) == ($temp_w*2))
 $dest_w = 180;
 $dest_h = 200;

 //Create the canvas.  To use imagecreatetruecolor you need 
php_gd2.dll listed as an extension
 $image_t = imagecreatetruecolor($dest_w, $dest_h);

 //Resize (technically resample) the image to the new canvas
 imagecopyresampled($image_t, $tempimage, 0, 0, 0, 0, $dest_w, 
$dest_h, $temp_w, $temp_h);

 //Save the Thumbnail
 if(!ImageJpeg($image_t, $image_root.$smallfilename))
 echo ERROR: Thumbnail Image unable to Upload!;
//Clean up

//Insert File info into MySQL database
$imageUpdate = insert into images (catID, caption, descr, systemID, 
genreID, game) values ('$f_imageCat', '$f_caption', '$f_descr', 
'$f_system', '$f_genre', '$f_game');

if(!mysql_query($imageUpdate, $conn))
 echo ERROR: Unable to Submit information to Database, try Upload 
echo BRBRfont size=3Image Upload Successful! Image ID is: $newnum;

I am running a windows system, so I know that the JPEG functions do work.
Gif functions will NOT WORK as the compression algorithm is now copyrighted.
If this script (once tweaked for your system needs) does not work and your 
php.ini file is included the proper extension I don't know what to say.


I believe the jpeg funnktions don't work on a windows system. The Gifs don't
do either because they aren't implemeted too.

Please look at this Library. It's very nice but I don't get it working and
the guy who made it don't know either, why it's not working on my system.
Must be something about jpeg librarys and so on.


PS.: Examples at the end of the file.

-Ursprüngliche Nachricht-
Von: Nicholas Mercier [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 13. August 2002 10:35
Betreff: Re: [PHP] image function

PHP General Mailing List (
To unsubscribe, visit: