homepage Welcome to WebmasterWorld Guest from 50.17.86.12
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Dynamically creating an image with imagecreate()
Is there a way to use imagecreate() without specifying the sizes?
ProductivePC

10+ Year Member



 
Msg#: 3981 posted 4:28 pm on Jun 2, 2004 (gmt 0)

I have a multitude of images that I am trying to bring up dynamically depending on the scenario. These images are different sizes.
To complicare things just a little more, I am rewriting a javaScript. Am I heading into the correct direction?

Here is the original JS that I am attempting to rewrite: (This is most of the way translated to PHP)

<?php
// if no usr or project set then display visibile

// if usr=="someuser" then display visibile

if($sc_error==1) {
echo("Code corrupted. Insert fresh copy.");
}
else if($sc_remove==1) {
echo("<b>StatCounter cannot track a high volume website like yours for free. This was stated several times during the sign up process. Please remove the code ASAP.</b>");
}

else if ($sc_text) {
echo("<scr" + "ipt language=\"JavaScript\"" + " src=" + $sc_tracking_url + "></scr" + "ipt>");
}
else if ($sc_invisible) {
if($sc_invisible==1) {

//This is the part I am having trouble with

sc_img = new Image();
sc_img.src = sc_tracking_url;

}
else {
echo("<A HREF=\"http://www.StatCounter.com\" TARGET=\"_blank\"><IMG SRC=\""+sc_tracking_url+"\" ALT=\"StatCounter - Free Web Tracker and Counter\" BORDER=\"0\"><\/A>");
}
}
else {
echo("<A HREF=\"http://www.StatCounter.com\" TARGET=\"_blank\"><IMG SRC=\""+sc_tracking_url+"\" ALT=\"StatCounter - Free Web Tracker and Counter\" BORDER=\"0\"><\/A>");
}
?>
ss_tracking_url is the image retrieved from statcounter.com's website.

The below is taken from php.net but I could not see a way of making the width and height attributes to say whatever the image that I am putting on the page is.

resource imagecreate ( int x_size, int y_size)
imagecreate() returns an image identifier representing a blank image of size x_size by y_size.

This is the very last part on this conversion... Any help would be greatly appreciated... Thank you in advance.

Wayne

 

coopster

WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3981 posted 12:05 am on Jun 3, 2004 (gmt 0)

I believe that is simply javascript to create a placeholder for a new image, which is then directed to be loaded from the url specified. Do you really need to create a new palette based image? Or simply load it from the external url?

ProductivePC

10+ Year Member



 
Msg#: 3981 posted 12:53 am on Jun 3, 2004 (gmt 0)

What I am utlimately trying to accomplish is this. I use statcounter for a tracker on our website. Statcounter is in a js file write now written in JavaScript. you can view this js file here [http]

This JavaScript has references to http:// so I cannot use it on our https pages otherwise it throws up a warning. I have rewritten the whole thing in PHP with the hopes that the browser will not care about the port 80 references since they are not be rendered in the HTML code.

The last part that I have is that image() function. I have to keep the code exactly, or at least as close to the statcounter code as I can for it to function properly.

What that function does is if certain conditions do not apply then it will put an image from the statcounter website and place it on your webpage. The image that it pulls is depending on what image you have selected in your administrative control panel at the statcounter website.

is this feasible

<?php

$sc_tracking_url= '<script language=\"javaScript\">
sc_img = new Image();
sc_img.src = sc_tracking_url;
</script>'
?>

Then I would be able to make references to the $sc_tracking_url anytime I would like within the PHP file as long as whatever I am trying to reference is after that code... is that correct?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved