Filename generating

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
wattee
Forum Newbie
Posts: 12
Joined: Mon Nov 02, 2009 5:00 am

Filename generating

Post by wattee »

Hi

I have a problem with generating enough filenames.

I have 2 functions,

The base of the 1st function is this:

Code: Select all

  foreach ($arry as $i => $ystart) {
				$pic = $this->pilt();
                $pic->cropImage(256,256,$xstart,$ystart);  
	   			$failinimi = "bunny/bunny_0" . $i . ".png";    
	            $pic->writeImages($failinimi, false); 

        }
What it does is that it takes an image crops it vertically like a column into 256pixel pieces. $ystart array has values inside the function and $xstart array gets passed in.
Now the problem is the auto generating filename, since width is usually wider than heigth it only generates filename numbers as much there is height pieces. Therego it overwrites the picture files as many times there are width pieces($xstart).
What i want is to get all the sliced images with different names. As if there was 24 pieces(like 4 height, 6 width) i'd name them 1-24.


This is from my other function, passing the argument.

Code: Select all

foreach ($arrx as $xstart){
			$this->loigu($xstart);
 
		}

Would greatly appreciate the help you can give me.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Filename generating

Post by AbraCadaver »

I'm not totally sure because I can't tell what all of the arrays are or what the functions do, but maybe something like this:

Code: Select all

foreach  ($arrx as  $k => $xstart){
   $this->loigu($xstart, $k); 
}
Then in your function you need to take another argument and do this:

Code: Select all

function loigu($xstart, $number) {
   foreach ($arry as $i => $ystart) {
      $pic = $this->pilt();
      $pic->cropImage(256,256,$xstart,$ystart);  
      $failinimi = "bunny/bunny_" . $number . $i . ".png";    
      $pic->writeImages($failinimi, false);
   }
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
wattee
Forum Newbie
Posts: 12
Joined: Mon Nov 02, 2009 5:00 am

Re: Filename generating

Post by wattee »

hey, thanks a bunch. it worked
Post Reply