Jump to content

Request exceeded the limit of 10 internal redirects


The Little Guy

Recommended Posts

I think I have worked my way into finding a location to this problem, but I have not pin pointed the exact location.

 

I have a script that takes images and uses the gd library, the following are in a loop:

 

$img = imagecreatefromjpeg($image);
$width = imagesx($img);
$height = imagesy($img);
$rgb = ImageColorAt($img, $w, $h);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >>  & 0xFF;
$b = $rgb & 0xFF;
imagedestroy($img);

 

I am taking the code I wrote here (jpg to ascii):

http://phpsnips.com/snippet.php?id=29

 

And I am modifying it to process more images and save them to an html file

 

I am not sure what is giving me this error, is it the fopen/write or is it the gd functions?

If I do it with say 900 images it works fine, I have tried doing it with 1,800 images and that is where it throws a 500 error

 

private function jpg2ascii(){
	$images = glob(getcwd().'/'.$this->images.'/'.$this->fileName.'*.jpg');
	if(is_file(getcwd().'/'.$this->html.'/'.$this->fileName.'.html')){
		unlink(getcwd().'/'.$this->html.'/'.$this->fileName.'.html');
	}
	$handle = fopen(getcwd().'/'.$this->html.'/'.$this->fileName.'.html', 'a');
	$i = 1;
	foreach($images as $image){
		$img = imagecreatefromjpeg($image);
		$width = imagesx($img);
		$height = imagesy($img);
		$opt = '';
		for($h=0;$h<$height;$h++){
			for($w=0;$w<=$width;$w++){
				$rgb = ImageColorAt($img, $w, $h);
				$r = ($rgb >> 16) & 0xFF;
				$g = ($rgb >>  & 0xFF;
				$b = $rgb & 0xFF;
				if($w == $width){
					$opt .= "\n";
				}else{
					// max = 768: white
					// min = 000: black
					$col = $r + $g + $b;
					if($col > 605)
						$txt = $this->tones[4];
					elseif($col > 442)
						$txt = $this->tones[3];
					elseif($col > 279)
						$txt = $this->tones[2];
					elseif($col > 116)
						$txt = $this->tones[1];
					else
						$txt = $this->tones[0];
					$opt .= $txt;
				}
			}
		}
		imagedestroy($img);
		fwrite($handle, $opt);
		unlink($image);
		$i++;
	}
	fclose($handle);
}

 

[sat Feb 26 14:39:39 2011] [error] [client 96.42.108.211] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.