FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Why no Text after image 1?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Why no Text after image 1? [message #173504] Sat, 16 April 2011 05:21 Go to next message
OhNoes is currently offline  OhNoes
Messages: 2
Registered: April 2011
Karma: 0
Junior Member
I put together a script from a bunch of papges from php.net and don't
understand why I get what I expect from the first image but not the
subsequent ones. Expecting a dark grey background with some tect
written and then it saves as a jpg.

I'm taking some old security tapes and breaking them into ten minute
clips. The jpegs from this script will be inrto scenes for my clips.
Made a csv from excel because the dates are mostly weekdays and have a
list in excel already. With that list I know I will have 4 two hour
tapes or 48 ten minute clips and can crank out a csv easy. That and
wanted to see if I could get a csv imprt to work.

Why is there no text fo pictures 2-48??? Part 1 is great. Shouldn't
imagedestroy clear everything or is it in the wrong spot?

I would really like to use imagettftext but could not for the life of
me figure out how to measure the string from the examples on the page.

Thanks for any help!


Here is my code:
<?php
$y=0;

$row = 1;
if (($handle = fopen("Part1_48.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
// echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
//echo nl2br($data[$c]);

header("Content-type: image/jpeg");

$width = 640;
$height = 480;
$picture = imagecreate($width,$height);
$background = imagecolorallocate($picture, 51, 51, 51);
$text_color = ImageColorAllocate ($picture, 255, 255, 255);

$TextLine1 = "This is the First Line";
$TextLine2 = "Second Line";
$TextLine3 = "Put Date of Tape Here";
$TextLine4 = $data[$c];

// Line 1
$font_size = 5;
$text_width = imagefontwidth($font_size)*strlen($TextLine1);
$center = ceil($width / 2);
$x = $center - (ceil($text_width/2));
$y = $y + 50;
imagestring($picture, $font_size, $x , $y, $TextLine1, $text_color);

// Line 2
$font_size = 5;
$text_width = imagefontwidth($font_size)*strlen($TextLine2);
$center = ceil($width / 2);
$x = $center - (ceil($text_width/2));
$y = $y + 50;
imagestring($picture, $font_size, $x , $y, $TextLine2, $text_color);

// Line 3
$font_size = 5;
$text_width = imagefontwidth($font_size)*strlen($TextLine3);
$center = ceil($width / 2);
$x = $center - (ceil($text_width/2));
$y = $y + 50;
imagestring($picture, $font_size, $x , $y, $TextLine3, $text_color);

// Line 4
$font_size = 5;
$text_width = imagefontwidth($font_size)*strlen($TextLine4);
$center = ceil($width / 2);
$x = $center - (ceil($text_width/2));
$y = $y + 50;
imagestring($picture, $font_size, $x , $y, $TextLine4, $text_color);


ImageJPEG($picture);
imageJPEG($picture,"images/".$TextLine4.".jpg", 100);
ImageDestroy($picture);

}
}
fclose($handle);
}
?>
Re: Why no Text after image 1? [message #173505 is a reply to message #173504] Sat, 16 April 2011 06:43 Go to previous message
OhNoes is currently offline  OhNoes
Messages: 2
Registered: April 2011
Karma: 0
Junior Member
On 2011-04-15 22:21:14 -0700, OhNoes <BooHaHa(at)usenet(dot)org> said:
<snip>
>
>
> Here is my code:
> <?php
> $y=0;

>
<snip>

Guess that was the culprit and it only took an hour to find.

All the images have text now. Also made the same script create .png's
to see if they looked better. Were twice as big but the jpeg's looked
better.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How many PHP calls is too many for one webpage?
Next Topic: regexp
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 15:50:31 GMT 2024

Total time taken to generate the page: 0.02696 seconds