Files to directories
Posted: Tue May 25, 2010 4:45 am
Hi,
bah i keep running to dead ends.
I have a function with what i would like to do the following:
I would like to take in a picture object, reduce the size by / 2 with the end of 1x1 pixel img,
create as many folders as there are generated pictures, ie. a pic 1920x1080 would generate folders from 0-10 (calculated by the wider side).
Now with what im stuck with is that it generates 1 picture less. It doesnt generate 1x1 pixel img, and all the files images have shifted, the biggest img is not in 10th folder
but 9th. Here's my code:
Dont mind the language, eh. Im beginning to think that taking params for resizing from an array isn't such a good idea after all, or isit? Any help is appreciated
bah i keep running to dead ends.
I have a function with what i would like to do the following:
I would like to take in a picture object, reduce the size by / 2 with the end of 1x1 pixel img,
create as many folders as there are generated pictures, ie. a pic 1920x1080 would generate folders from 0-10 (calculated by the wider side).
Now with what im stuck with is that it generates 1 picture less. It doesnt generate 1x1 pixel img, and all the files images have shifted, the biggest img is not in 10th folder
but 9th. Here's my code:
Code: Select all
function suurus(){
$pic = $this->pilt();
$korgus = $pic->getImageHeight();
$pikkus = $pic->getImageWidth();
for($i=$pikkus; $i>=1; $i=$i-$i/2)
{
$kaustadp[] = $i;
}
for($i=$korgus; $i>=1; $i=$i-$i/2)
{
$kaustadk[] = $i;
}
if ($pikkus > $korgus) {
$kaustad = $kaustadp;
} else {
$kaustad = $kaustadk;
}
end($kaustadp);
end($kaustadk);
foreach ($kaustad as $nr => $kaust) {
if(!file_exists('pildid/test/'.$nr)) {
mkdir('pildid/test/'.$nr.'/', 0777, true);
}
$pic = $this->pilt();
$pic->resizeImage(prev($kaustadp), prev($kaustadk), Imagick::FILTER_CATROM,1);
$pic->writeImage('pildid/test/'.$nr.'/bunny.png');
}
}Dont mind the language, eh. Im beginning to think that taking params for resizing from an array isn't such a good idea after all, or isit? Any help is appreciated