What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Assistance with PHP and GD

Assistance with PHP and GD
Author: Message:
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. Assistance with PHP and GD
I'm in the middle of trying to optimize the php code thats used to generate the images for YASS, cleaning up code, reducing variables and whatnot. In order to help find bottlenecks, I am sending header information containing execution time and memory usage at various points in the script. I ended up graphing them in Excel too, which I have attached for anyone interested. On the graph itself, ignore the last 2 points. the second last one i used a different function to get the memory usage. The last one is the same on all graphs so that they would all be at the same scale.

I basically have 2 bottlenecks right now, the first is using imagecopy/imagecopyresized to create the background for all images. Chances are, this won't be able to be reduced too much.

The second bottleneck is calling imagepng to create the final image. As I have the code right now, the sequence of events is, imagepng is called, and the image created is written to a file. A few lines later, this file is read from disk and sent to the browser. What I want to happen, if possible, is for imagepng to be called, have the image stored in memory, sent to the browser, and then written to disk. Basically, saving from having to do a disk read.

The problem is, imagepng returns a boolean value for if the operation is successful, and not the data for the image. I have no idea if its possible to capture the output buffer to a variable or not, or if this order of events would even be possible.

Any ideas on how to improve it?

The actual code as it is now:
code:
$success = imagepng($main_image, $imgfile);
if ($success = FALSE){
   die('Error creating image');
}else{
   // run a SQL query
}
//output header information, and then the final image.
header('Content-type: image/png');
Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
Header("Expires: Sat, 01 Jan 2000 01:00:00 GMT");
Header("Pragma: no-cache");
       
readfile($imgfile);
imagedestroy($main_image);


On a side note, why are .xls files not allowed to be uploaded?

.zip File Attachment: execTimes.zip (5.9 KB)
This file has been downloaded 163 time(s).

This post was edited on 02-21-2008 at 07:02 PM by MeEtc.
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
02-21-2008 06:57 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Assistance with PHP and GD - by MeEtc on 02-21-2008 at 06:57 PM
RE: Assistance with PHP and GD - by WDZ on 02-21-2008 at 07:18 PM
RE: Assistance with PHP and GD - by Matti on 02-21-2008 at 07:22 PM
RE: Assistance with PHP and GD - by MeEtc on 02-21-2008 at 07:34 PM
RE: Assistance with PHP and GD - by ShawnZ on 02-21-2008 at 09:00 PM
RE: Assistance with PHP and GD - by MeEtc on 02-21-2008 at 09:15 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On