PDA

View Full Version : Random Image works as direct link, but doesn't work in the IMG tag...


wooolF[RM]
06-27-2002, 09:51 PM
]Hello everyone... I used following script to push a random picture:<?php
$logodir = "http://www.somewhere.com/pics/";

header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');

$logos = array
(
$logodir . "1.jpg",
$logodir . "2.jpg",
$logodir . "3.jpg",
$logodir . "4.jpg",
$logodir . "5.jpg",
$logodir . "6.jpg"
);

function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());

$logo = rand(0, count ($logos) - 1);
$titleimage = $logos[$logo];
?>

<?php
echo "<img src=$titleimage>";
?>Then I saved that script as sig.php and uploaded in the same folder where pics are. Then I checked http://www.somewhere.com/pics/sig.php and it worked like a charm...

Now... I went to my VBB forum and made a new VBB code :

vB Code tag
adminimgonly

vB Code replacement
<img src="{param}">

vB Code example
http://www.google.com/images/logo.gif

vB Code explanation
Adds an IMAGE to a signature for ADMINS only.

Use {option} ?
Yes No

And tried it out in my signature as http://www.somewhere.com/pics/sig.php . Do u think it worked? nope! :(
But direct access http://www.somewhere.com/pics/1.jpg to the picture worked fine (just showing that this vBB code works perfectly)

In the source code I could clearly see plain html language< img src="http://www.somewhere.com/pics/sig.php" > which should work but didn't (showed only place for the pix with X in the top left corner of it) :(

Anyone have any ideas? :(

shovel
06-27-2002, 10:29 PM
&nbsp;&nbsp;&nbsp;&nbsp;Just a question but have you had any regular registered members try it to see if it works?

wooolF[RM]
06-27-2002, 10:43 PM
]nope I haven't... I tried it on another pc at the same home network - same result :(

shovel
06-28-2002, 02:45 PM
&nbsp;&nbsp;&nbsp;&nbsp;I think personally that the direct link is plainly bypassing as an image tag like:
[*img]the image address[*/img]
Would be just as:
http://www.somewhere.com/pics/1.jpg
Do you have html or php enabled in the signatures?

wooolF[RM]
06-29-2002, 11:46 AM
no, html/php + img tag is disabled... that's why I made new vBB code...

Xenon
06-29-2002, 01:05 PM
woolfe try this code in your sig.php file:


<?php
$logodir = "http://www.somewhere.com/pics/";

header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');

$logos = array
(
$logodir . "1.jpg",
$logodir . "2.jpg",
$logodir . "3.jpg",
$logodir . "4.jpg",
$logodir . "5.jpg",
$logodir . "6.jpg"
);

function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());

$logo = rand(0, count ($logos) - 1);

$im = imagecreatefromjpeg($logos[$logo]);
Imagejpeg($im);
Imagedestroy($im);
?>

wooolF[RM]
06-29-2002, 01:42 PM
]lemme try :)

(will edit this message as soon as I have tried :) )

wooolF[RM]
06-29-2002, 01:43 PM
erm....

$im = imagecreatefromjpeg($logos[$logo]<img src="https://vborg.vbsupport.ru/images/newsm/wink.gif" border="0" alt="">;

^^^^^^ ????

wooolF[RM]
06-29-2002, 02:03 PM
]well... I used script as u said and it didn't worked... then I changed


$im = imagecreatefromjpeg($logos[$logo]<img src="https://vborg.vbsupport.ru/images/newsm/wink.gif" border="0" alt="">;

to

$im = imagecreatefromjpeg($logos[$logo]<img src=" ; ) " border="0" alt="">;


same result - doesn't work...


Parse error: parse error, unexpected T_STRING in /blabla/sig.php on line 27where line 27 is the line I have changed

Xenon
06-29-2002, 04:31 PM
ups, seems vb has parsed a line as a smilie *gg*
try now

wooolF[RM]
06-29-2002, 07:05 PM
]<br />
<b>Fatal error</b>: Call to undefined function: imagecreatefromjpeg() in <b>/blabla/sig.php</b> on line <b>27</b><br />where line 27 is$im = imagecreatefromjpeg($logos[$logo]);

wooolF[RM]
06-29-2002, 07:08 PM
]the code I use right now looks like this: (just making sure we are talking about same script and same things)
<?php
$logodir = "http://www.somewhere.com/pics/";

header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');

$logos = array
(
$logodir . "1.jpg",
$logodir . "2.jpg",
$logodir . "3.jpg",
$logodir . "4.jpg",
$logodir . "5.jpg",
$logodir . "6.jpg"
);

function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());

$logo = rand(0, count ($logos) - 1);

$im = imagecreatefromjpeg($logos[$logo]);
Imagejpeg($im);
imagedestroy($im);

?>

Xenon
06-30-2002, 01:10 PM
hmm, look here:
http://www.php.net/manual/en/function.imagecreatefromjpeg.php

its a standartfunction in php.
something with your php-installation seems not to be ok...

wooolF[RM]
06-30-2002, 01:28 PM
]I have tried it on 2 servers now... one in Germany and one in Holland. Both are installed by 2 difefrent peoples. Same result - doesn't work :confused:

wooolF[RM]
06-30-2002, 01:34 PM
]by the way... I don't blame you or something... I really appreciatte all your help... but I can't see meaning of creating an image from an EXISTED image, show it and then destroy it...

why not just push the existed image? :confused:

Xenon
06-30-2002, 01:34 PM
have tried it at my server, works perfect:
http://www.strategy-forum.de/test.php

Xenon
06-30-2002, 01:51 PM
Originally posted by wooolF[RM]
by the way... I don't blame you or something... I really appreciatte all your help... but I can't see meaning of creating an image from an EXISTED image, show it and then destroy it...
why not just push the existed image? :confused:

i don't know why, its just the way php wants it ;)

hmm, maybe your servers have disabled this function, have tested it on another server too and works perfectly too

wooolF[RM]
06-30-2002, 02:09 PM
]ok... I got my friend to use it on his server (3rd server I'm trying to get it workk on).

It works! yay! now the problem is : all 6 pics I used was 25-30kb in size in perfect quality. After randomizing by this script all I get is blurred, low quality picture 8-9kb in size...

are there any ways to be sure that qulity at the end is the same as in the start?

btw : thanx for this workaround :)

wooolF[RM]
06-30-2002, 03:27 PM
]Anyway, here's updated version of my script that should at the output generate progressive JPEG with 100% quality.


<?php

/* Location of the pictures */
$logodir = "http://www.mpc.turbohost.net/wolfsig/";

/* Type of output (for browsers) */
header('Content-Type: image/jpeg');

/* No caching (for newer browsers) */
header('Cache-Control: no-store, no-cache, must-revalidate');

/* No caching (for older browsers) */
header('Pragma: no-cache');


/* Making an array with all pictures */
$logos = array
(
$logodir . "1.jpg",
$logodir . "2.jpg",
$logodir . "3.jpg",
$logodir . "4.jpg",
$logodir . "5.jpg",
$logodir . "6.jpg"
);


/* explode = explode an array */
/* microtime = return current UNIX timestamp with microseconds */

function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}

/* explode = seed the random number generator */
srand(make_seed());


/* rand = seed the random number generator */
/* count = count elements in a variable */
$logo = rand(0, count ($logos) - 1);

/* Create image from predefined variables */
$im = ImageCreateFromJPEG($logos[$logo]);

/* Output image as a progressive JPEG */
imageinterlace($im,1);

/* Output image with 100% quality */
Imagejpeg($im,'', 100);

/* Destroy picture on the server */
imagedestroy($im);

?>



As always... Script is working but there's some problems with it : generated pictures are not in the same quality as input pictures.

wooolF[RM]
06-30-2002, 03:47 PM
forget it... I'm using other script