From 6628507cd34f0f72aa9862fcc87869c752bc3dd2 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Tue, 14 Aug 2012 18:46:02 +0200 Subject: [PATCH] Added examples --- examples/example1.php | 14 ++++++++++++++ examples/example2.php | 18 ++++++++++++++++++ examples/example3.php | 38 ++++++++++++++++++++++++++++++++++++++ examples/example4.php | 30 ++++++++++++++++++++++++++++++ examples/example5.php | 13 +++++++++++++ examples/example6.php | 18 ++++++++++++++++++ examples/index.htm | 12 ++++++++++++ 7 files changed, 143 insertions(+) create mode 100644 examples/example1.php create mode 100644 examples/example2.php create mode 100644 examples/example3.php create mode 100644 examples/example4.php create mode 100644 examples/example5.php create mode 100644 examples/example6.php create mode 100644 examples/index.htm diff --git a/examples/example1.php b/examples/example1.php new file mode 100644 index 0000000..60dc0f3 --- /dev/null +++ b/examples/example1.php @@ -0,0 +1,14 @@ +rotate(90); + +//and we can resize and crop it to have a nice thumbnail +$image->resize(150,150,'crop'); + +//lets see what we have! +$image->display(); \ No newline at end of file diff --git a/examples/example2.php b/examples/example2.php new file mode 100644 index 0000000..051358c --- /dev/null +++ b/examples/example2.php @@ -0,0 +1,18 @@ +rotate(90); +$image->resize(150,150,'crop'); + +/* + Now save the file. First give a filename (without file extension, the class will figure it out!) + Then, optionally, give path to the folder where you want the image to be saved. + Of course, this directory will have to be writable! */ +$image->save("newFilename", "../test"); + +/* + and... oh pretty wow! If the path of the image is accessible to the browser + you can now even display the whole HTML code of the -Tag */ +$image->displayHTML(); \ No newline at end of file diff --git a/examples/example3.php b/examples/example3.php new file mode 100644 index 0000000..c1c1c61 --- /dev/null +++ b/examples/example3.php @@ -0,0 +1,38 @@ +resize(300,100); +$image->save('fit', $pathToSaveFiles); +$image->displayHTML(); + + +/* + If you set the option 'fill' the image will fill the whole width and + height you provided. But it will loose it aspect ratio. So be ready + to see your image deformed.*/ + +$image = new Image($mainImage); +$image->resize(300,100, 'fill'); +$image->save('fill', $pathToSaveFiles); +$image->displayHTML(); + + +/* + If you choose to 'crop' the image, it won't lose its aspect ratio but + parts of the image will be cut off. */ + +$image = new Image($mainImage); +$image->resize(300, 100, 'crop'); +$image->save('crop', $pathToSaveFiles); +$image->displayHTML(); \ No newline at end of file diff --git a/examples/example4.php b/examples/example4.php new file mode 100644 index 0000000..39b72d1 --- /dev/null +++ b/examples/example4.php @@ -0,0 +1,30 @@ +resize(400, 400, 'crop', 'l', 'b'); +$image->save('left-bottom', $pathToSaveFiles); +$image->displayHTML(); + +$image = new Image($mainImage); +$image->resize(400, 400, 'crop', 'r', 't'); +$image->save('right-top', $pathToSaveFiles); +$image->displayHTML(); + +$image = new Image($mainImage); +$image->resize(400, 400, 'crop', 'c', 'c'); +$image->save('center-center', $pathToSaveFiles); +$image->displayHTML(); \ No newline at end of file diff --git a/examples/example5.php b/examples/example5.php new file mode 100644 index 0000000..7b4ca6b --- /dev/null +++ b/examples/example5.php @@ -0,0 +1,13 @@ +checkRatio(1,2)){ + print 'Yes, you made it!'; +}else{ + print 'Sorry dude, the actual ratio is 1:' . round($image->getRatioWidthToHeight(), 2); +} \ No newline at end of file diff --git a/examples/example6.php b/examples/example6.php new file mode 100644 index 0000000..3991b6c --- /dev/null +++ b/examples/example6.php @@ -0,0 +1,18 @@ +getWidth().'
'; +print 'Height: '.$image->getHeight().'
'; +print 'Extension: '.$image->getExtension().'
'; +print 'Mime: '.$image->getMimeType().'
'; +print 'Type: '.$image->getType().'
'; +print 'Filesize in Bytes: '.$image->getFileSizeInBytes().'
'; +print 'Filesize in kBytes: '.$image->getFileSizeInKiloBytes().'
'; +print 'Filesize readable: '.$image->getFileSize().'
'; +print 'Ratio Width:Height: '.$image->getRatioWidthToHeight().'
'; +print 'Ratio Height:Width: '.$image->getRatioHeightToWidth().'
'; +print 'Is it RGB?: '.$image->isRGB(); diff --git a/examples/index.htm b/examples/index.htm new file mode 100644 index 0000000..ae133a9 --- /dev/null +++ b/examples/index.htm @@ -0,0 +1,12 @@ +

Some examples for class.Images.php

+ +

Here are some examples of what you can do with this class. Make sure to check the source code of those files as well as of the class itself as well as there are plenty of more parameters and options.

+ + \ No newline at end of file