mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-04 07:07:32 +02:00
initial release
This commit is contained in:
11
CImage.php
11
CImage.php
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Resizing images on the fly.
|
* Resize and crop images on the fly. Store generated images in a cache.
|
||||||
*
|
*
|
||||||
* @author Mikael Roos mos@dbwebb.se
|
* @author Mikael Roos mos@dbwebb.se
|
||||||
* @example http://dbwebb.se/example/lessphp/
|
* @example http://mikaelroos.se/cimage/test.php
|
||||||
* @link https://github.com/mosbth/Utility/blob/master/style.php
|
* @link https://github.com/mosbth/cimage
|
||||||
*/
|
*/
|
||||||
class CImage {
|
class CImage {
|
||||||
|
|
||||||
@@ -211,11 +211,6 @@ class CImage {
|
|||||||
* @param $imageQuality number the quality to use when saving the file, default is full quality.
|
* @param $imageQuality number the quality to use when saving the file, default is full quality.
|
||||||
*/
|
*/
|
||||||
public function ResizeAndSave($imageQuality="100") {
|
public function ResizeAndSave($imageQuality="100") {
|
||||||
|
|
||||||
//echo "{$this->width}:{$this->height}:{$this->mime}</br>";
|
|
||||||
//echo "{$this->cropWidth}:{$this->cropHeight}</br>";
|
|
||||||
//echo "{$this->newWidth}:{$this->newHeight}</br>";
|
|
||||||
|
|
||||||
if($this->crop) {
|
if($this->crop) {
|
||||||
$cropX = ($this->cropWidth/2) - ($this->newWidth/2);
|
$cropX = ($this->cropWidth/2) - ($this->newWidth/2);
|
||||||
$cropY = ($this->cropHeight/2) - ($this->newHeight/2);
|
$cropY = ($this->cropHeight/2) - ($this->newHeight/2);
|
||||||
|
2
img.php
2
img.php
@@ -30,5 +30,5 @@ if(isset($newHeight)) {
|
|||||||
|
|
||||||
// Create the image object
|
// Create the image object
|
||||||
require(__DIR__.'/CImage.php');
|
require(__DIR__.'/CImage.php');
|
||||||
$img = new CImage($srcImage, $newWidth, $newHeight, $keepRatio, $crop, null/*$pathToCache*/);
|
$img = new CImage($srcImage, $newWidth, $newHeight, $keepRatio, $crop, $pathToCache);
|
||||||
$img->ResizeAndOutput();
|
$img->ResizeAndOutput();
|
3
test.php
3
test.php
@@ -13,7 +13,10 @@
|
|||||||
<li>crop: together with both h & w makes the image fit in the box.
|
<li>crop: together with both h & w makes the image fit in the box.
|
||||||
<li>no-ratio: do not keep aspect ratio.
|
<li>no-ratio: do not keep aspect ratio.
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>Sourcecode and issues on github: <a href='https://github.com/mosbth/cimage'>https://github.com/mosbth/cimage</a></p>
|
||||||
|
<p>Mikael Roos (mos@dbwebb.se)</p>
|
||||||
|
|
||||||
|
<h2>Testcases</h2>
|
||||||
<table>
|
<table>
|
||||||
<caption>Test cases</caption>
|
<caption>Test cases</caption>
|
||||||
<thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>
|
<thead><tr><th>Testcase:</th><th>Result:</th></tr></thead>
|
||||||
|
Reference in New Issue
Block a user