[TASK] Enhanced status report.
[TASK] BoxImageClass now has some getters for height and width.
This commit is contained in:
parent
fea4ee040c
commit
61ea2b936e
@ -145,4 +145,20 @@ class BoxImage {
|
|||||||
return imagepng($this->image, $filename, $compression);
|
return imagepng($this->image, $filename, $compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets height.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getHeight() {
|
||||||
|
return $this->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets width.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getWidth() {
|
||||||
|
return $this->width;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -36,7 +36,11 @@ class FileImageConverter {
|
|||||||
$filesize = filesize($filename);
|
$filesize = filesize($filename);
|
||||||
$md5 = md5_file($filename);
|
$md5 = md5_file($filename);
|
||||||
|
|
||||||
$new_filename = $filename."-converted.png";
|
echo "Processing '" . $filename . "' (" . $filesize . " Bytes) - MD5: " . $md5 . "\n";
|
||||||
|
|
||||||
|
$new_filename = basename($filename)."-converted.png";
|
||||||
|
|
||||||
|
echo "Filename for the result: '" . $new_filename . "'\n";
|
||||||
|
|
||||||
//some gradient
|
//some gradient
|
||||||
$fancy_header = "";
|
$fancy_header = "";
|
||||||
@ -53,9 +57,15 @@ class FileImageConverter {
|
|||||||
|
|
||||||
//create and prepare image
|
//create and prepare image
|
||||||
$this->image = new BoxImage($size);
|
$this->image = new BoxImage($size);
|
||||||
|
|
||||||
|
echo "Image will be " . $this->image->getWidth() . "px x " . $this->image->getHeight() . "px.\n";
|
||||||
|
|
||||||
|
echo "Filling image...";
|
||||||
$this->image->fillImage(0,0,0,0);
|
$this->image->fillImage(0,0,0,0);
|
||||||
|
echo "done.\n";
|
||||||
|
|
||||||
//some fancy header
|
//some fancy header
|
||||||
|
echo "Adding header...\n";
|
||||||
$this->addDataToImage($fancy_header);
|
$this->addDataToImage($fancy_header);
|
||||||
|
|
||||||
//magic pixel
|
//magic pixel
|
||||||
@ -63,6 +73,7 @@ class FileImageConverter {
|
|||||||
$this->image->movePointer(1);
|
$this->image->movePointer(1);
|
||||||
|
|
||||||
//add filesize
|
//add filesize
|
||||||
|
echo "Adding filesize...\n";
|
||||||
$this->addDataToImage($filesize);
|
$this->addDataToImage($filesize);
|
||||||
|
|
||||||
//magic pixel
|
//magic pixel
|
||||||
@ -70,6 +81,7 @@ class FileImageConverter {
|
|||||||
$this->image->movePointer(1);
|
$this->image->movePointer(1);
|
||||||
|
|
||||||
//add md5 value of content
|
//add md5 value of content
|
||||||
|
echo "Adding MD5-Hash...\n";
|
||||||
$this->addDataToImage($md5);
|
$this->addDataToImage($md5);
|
||||||
|
|
||||||
//magic pixel
|
//magic pixel
|
||||||
@ -77,6 +89,7 @@ class FileImageConverter {
|
|||||||
$this->image->movePointer(1);
|
$this->image->movePointer(1);
|
||||||
|
|
||||||
//content
|
//content
|
||||||
|
echo "Adding file contents...\n";
|
||||||
$this->addDataToImage($content);
|
$this->addDataToImage($content);
|
||||||
|
|
||||||
//magic pixel
|
//magic pixel
|
||||||
@ -84,7 +97,9 @@ class FileImageConverter {
|
|||||||
$this->image->movePointer(1);
|
$this->image->movePointer(1);
|
||||||
|
|
||||||
//save image
|
//save image
|
||||||
|
echo "Saving image...";
|
||||||
$this->image->writeToFile($new_filename, 9);
|
$this->image->writeToFile($new_filename, 9);
|
||||||
|
echo "done.\n";
|
||||||
|
|
||||||
//clean up
|
//clean up
|
||||||
unset($this->image);
|
unset($this->image);
|
||||||
@ -114,7 +129,7 @@ class FileImageConverter {
|
|||||||
echo "Caught Exception:\n";
|
echo "Caught Exception:\n";
|
||||||
echo $e;
|
echo $e;
|
||||||
}
|
}
|
||||||
echo "\rDone. \n";
|
echo "\rdone. \n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user