1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-29 02:19:47 +02:00

Compare commits

..

83 Commits
v0.2 ... v0.5.3

Author SHA1 Message Date
Mikael Roos
ccc59fbb3a Prepare to tag v0.5.3 2014-11-21 21:14:19 +01:00
Mikael Roos
e85bc6cee5 Adding testfiles with capital extension 2014-11-21 21:12:22 +01:00
Mikael Roos
3b7485b3b9 Support filenames of uppercase JPEG, JPG, PNG and GIF, as proposed in #37. 2014-11-21 21:01:22 +01:00
Mikael Roos
c83eac8c3c Changing CImage::output() as proposed in #37. 2014-11-21 20:20:35 +01:00
Mikael Roos
78ac29752e Adding security check that image filename is always below the path
`image_path` as specified in `img_config.php` #37.
2014-11-21 19:57:11 +01:00
Mikael Roos
4b64237a4c Changeing comment 2014-11-21 19:37:33 +01:00
Mikael Roos
85f0e3e7d3 moving testilfes to one dir 2014-11-21 19:35:04 +01:00
Mikael Roos
da227d49dd Use the new config item for checking valid filename characters. 2014-11-21 19:34:01 +01:00
Mikael Roos
26449a3236 Adding configuration item to set what valid characters are for the image
filename.
2014-11-21 19:32:05 +01:00
Mikael Roos
20a4f848b7 Moved all test-files into own directory. 2014-11-21 19:24:36 +01:00
Mikael Roos
ec3a6f3491 check if extension exif is loaded #36 2014-09-01 01:27:45 +02:00
Mikael Roos
8523ef5e31 adding testcases for #36 2014-09-01 00:38:26 +02:00
Mikael Roos
63112f58b1 Cleaning up code #23, added rotate and autoRotate #36 2014-08-31 23:58:02 +02:00
Mikael Roos
c96ed10f80 Cleaning up code #23, added rotate and autoRotate #36 2014-08-31 23:57:34 +02:00
Mikael Roos
67524bd090 Adding MIT license text as should be. 2014-08-21 02:46:00 +02:00
Mikael Roos
1f9a11747b Readding cache dir 2014-08-21 02:37:58 +02:00
Mikael Roos
4ed55d59e3 finally setting jpeg_ignore_warning to true #34 2014-08-21 02:30:32 +02:00
Mikael Roos
8dde82993b improving error handling when opening (non)-recoverable images 2014-08-21 02:23:15 +02:00
Mikael Roos
fb261b1b05 improving error handling when opening (non)-recoverable images 2014-08-21 02:22:20 +02:00
Mikael Roos
1a6cef6580 improving error handling when opening (non)-recoverable images 2014-08-21 02:21:32 +02:00
Mikael Roos
2643d4954f must have @ before open images, warning contra notice, recoverable and non recoverable 2014-08-21 02:13:01 +02:00
Mikael Roos
ef1d56085a Verbose error when failing to open image 2014-08-21 02:08:49 +02:00
Mikael Roos
28cda0ea28 changing error handling to dir when failing to open a corrupt image 2014-08-21 02:02:50 +02:00
Mikael Roos
ed9949b717 adding corrupt jpegs for #34 2014-08-21 01:37:05 +02:00
Mikael Roos
c249a472d6 adding pre 2014-08-21 01:25:19 +02:00
Mikael Roos
c8c2e5f95f updated with change #34 2014-08-21 01:20:50 +02:00
Mikael Roos
8db8501eb0 Setting gd.jpeg_ignore_warning to true #34 as default 2014-08-21 01:19:56 +02:00
Mikael Roos
2b0b3859a7 Extended info printed #35 2014-08-21 00:31:05 +02:00
Mikael Roos
1e70883771 Now sends 404 header as it should #32 when providing a error page 2014-08-20 23:55:23 +02:00
Mikael Roos
b2002d0087 Now sends 404 header as it should #32 when providing a error page 2014-08-20 23:54:13 +02:00
Mikael Roos
9aac0cde8e Removed old description, its in the README now, focus on testcases. 2014-08-20 23:49:25 +02:00
Mikael Roos
3dec1d0a6d Merge pull request #33 from garagesocial/patch-2
Update CImage.php
2014-08-15 08:54:59 +02:00
Garagesocial
577e5fa5d4 Update CImage.php 2014-08-15 02:07:07 -04:00
Mikael Roos
38a6c86317 Merge pull request #31 from garagesocial/patch-1
Comment Typo CImage.php
2014-08-07 08:18:17 +02:00
Garagesocial
dcb390a17b Comment Typo CImage.php 2014-08-06 19:02:55 -04:00
Mikael Roos
9e461787c7 comment reflected wrongly to area variabel, issue #29 2014-05-20 01:39:51 +02:00
Mikael Roos
a96cd7a4cc changed colors 2014-05-20 01:15:53 +02:00
Mikael Roos
98d971204f correcting links to image 2014-05-20 01:04:26 +02:00
Mikael Roos
9707065b9e trying and failing to verify issue 29 2014-05-20 00:56:30 +02:00
Mikael Roos
5cd953b9b3 issue 29 and code formatting 2014-05-20 00:56:08 +02:00
Mikael Roos
b4f51f3438 code formatting and making log() public 2014-05-20 00:55:43 +02:00
Mikael Roos
dedd01bc71 Helper to check if img.php is supported on this system 2014-05-20 00:12:46 +02:00
Mikael Roos
67d0cf27ee code formatting and slightly reformatted verbose output 2014-05-20 00:12:09 +02:00
Mikael Roos
161fdfe769 code formatting 2014-05-20 00:00:27 +02:00
Mikael Roos
6cff9ac105 better error reporting for development environment 2014-05-19 23:59:50 +02:00
Mikael Roos
ec42c41e4d Verified known bug - sharpen acts as blur in PHP 5.5.9 and 5.5.10 #28 2014-04-01 08:56:38 +02:00
Mikael Roos
f12d02b8c1 Correcting issue #27 and removing default config-options from img.php 2014-04-01 08:44:38 +02:00
Mikael Roos
1673cd7aca Correcting issue #26 2014-04-01 08:11:49 +02:00
Mikael Roos
0fee846437 tag v0.5.1 2014-02-12 15:29:58 +01:00
Mikael Roos
c63747a892 Adding empty cache-directory to repo 2014-02-12 15:25:29 +01:00
Mikael Roos
2d8cccc795 Display image in README 2014-02-12 15:22:52 +01:00
Mikael Roos
bb5fd6f115 Display image in README 2014-02-12 15:22:06 +01:00
Mikael Roos
0ab7cf7e1b prepare to tag v0.5 2014-02-12 15:09:29 +01:00
Mikael Roos
20a621bf48 prepare to tag v0.5 2014-02-12 14:45:25 +01:00
Mikael Roos
7478b12751 separating config-issues from img.php to own config-file 2014-02-10 19:43:40 +01:00
Mikael Roos
570fe57240 Fixed issue 1 and prepare to tagg v0.4.1 2014-01-27 13:21:59 +01:00
Mikael Roos
28f3c55d8c Fixed issue 1 and prepare to tagg v0.4.1 2014-01-27 13:19:07 +01:00
Mikael Roos
230e9189a3 correcting jpeg when setting quality 2013-10-15 01:25:29 +02:00
Mikael Roos
e886c86f72 allow negative values for crop width & height 2013-10-15 01:20:58 +02:00
Mikael Roos
d7b6f7e25d crop=0,0 for whole width and height 2013-10-15 01:11:13 +02:00
Mikael Roos
7849f69801 support jpeg file extension 2013-10-15 01:01:15 +02:00
Mikael Roos
7117ac2a4c always send last-modified header 2013-10-14 09:22:21 +02:00
Mikael Roos
c03ebedc93 comment postprocessing 2013-10-08 02:32:00 +02:00
Mikael Roos
c9d41ceca2 after testing for v0.4 2013-10-08 02:17:03 +02:00
Mikael Roos
218bd9491a adding cache directory 2013-10-08 02:07:55 +02:00
Mikael Roos
d8a65ae409 added usage to readme 2013-10-08 00:04:31 +02:00
Mikael Roos
c59f44f366 added usage to readme 2013-10-08 00:03:05 +02:00
Mikael Roos
688cd5c000 added usage to readme 2013-10-08 00:02:20 +02:00
Mikael Roos
60c76653b3 added usage to readme 2013-10-07 23:59:22 +02:00
Mikael Roos
47e5cb2327 adding images 2013-10-07 23:50:53 +02:00
Mikael Roos
04fd68cb2b A lot of updates when preparing for release. 2013-10-03 18:19:10 +02:00
Mikael Roos
664fd6a3be A lot of updates when preparing for release. 2013-10-03 18:16:33 +02:00
Mikael Roos
fedbf9e381 unintetionally removed README-file 2012-10-03 00:26:22 +02:00
Mikael Roos
28b107e64f Corrected error on calculation of height and width for crop-to-fit 2012-10-03 00:24:15 +02:00
Mikael Roos
ce63730cb6 correcting filenaming in cache dir 2012-10-02 23:41:27 +02:00
Mikael Roos
0482744f89 correcting filenaming in cache dir 2012-10-02 23:41:01 +02:00
Mikael Roos
0998f2819e correcting filenaming in cache dir 2012-10-02 23:40:32 +02:00
Mikael Roos
9e3c7fae82 Prepare tagging v0.3 2012-10-02 23:25:03 +02:00
Mikael Roos
e4c436f52c preparing to tag latest changes 2012-10-02 23:00:39 +02:00
Mikael Roos
5ac715aa48 preparing to tag latest changes 2012-10-02 22:59:14 +02:00
Mikael Roos
0593fec8fb preparing to tag latest changes 2012-10-02 22:58:11 +02:00
Mikael Roos
81f05147aa preparing to tag latest changes 2012-10-02 22:57:05 +02:00
Mikael Roos
12109803cc preparing to tag latest changes 2012-10-02 22:49:43 +02:00
49 changed files with 3005 additions and 413 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Cache files #
######################
cache/*

1957
CImage.php

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,21 @@
This is a software solution to a general known problem.
Free software. Use at own risk.
The MIT License (MIT)
Copyright (c) 2012 - 2014 Mikael Roos, me@mikaelroos.se
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

242
README.md
View File

@@ -1,40 +1,239 @@
Image conversion on the fly using PHP
=====================================
The `CImage.php` contains a class that can resize and crop images and output them to
a webpage. The class has cache of generated images.
About
-------------------------------------
The file `img.php` uses `CImage.php` to resize images. It is a usecase on how to use
the class.
`CImage` is a PHP class which enables resizing of images through scaling and cropping together with filtering effects, all using PHP GD. The script `img.php` uses `CImage` to enable server-side image processing together with caching and optimization of the processed images.
The file `test.php` has some testcases that show the results of `img.php` with different
settings.
Server-side image processing is a most useful tool for any web developer, `img.php` has an easy to use interface and its quite powerful when you integrate it with your website. Using it might decrease the time and effort put in managing images and improve your work flow when creating content for websites.
Start by reviewing the `test.php`, then have a look at `img.php` and finally go through
`CImage.php`.
Read more on http://dbwebb.se/opensource/cimage
Enjoy!
Mikael Roos (me@mikaelroos.se)
License
-------------------------------------
This is free software and open source software, licensed according MIT.
Installation and get going
-------------------------------------
**Latest stable version is v0.5.2 released 2014-04-01.**
```bash
git clone git://github.com/mosbth/cimage.git
cd cimage
git checkout v0.5.2
```
Make the cache-directory writable by the webserver.
```bash
chmod 777 cache
```
Try it out by pointing your browser to the test file `webroot/test.php`.
Review the settings in `webroot/img_config.php` and check out `webroot/img.php` on how it uses `CImage`.
Usage
-------------------------------------
###List of parameters
The `img.php` supports a lot of parameters. Combine the parameters to get the desired behavior and resulting image. For example, take the original image, resize it using width, aspect-ratio and crop-to-fit, apply a sharpen effect, save the image as JPEG using quality 30.
| `img.php?src=kodim13.png&w=600&aspect-ratio=4&crop-to-fit&sharpen&save-as=jpg&q=30` |
|-----------------------------------------------------------|
| <img src=http://dbwebb.se/kod-exempel/cimage_/webroot/img.php?src=kodim13.png&w=600&aspect-ratio=4&crop-to-fit&sharpen&save-as=jpg&q=30 alt=''> |
Here is a list of all parameters that you can use together with `img.php`, grouped by its basic intent of usage.
####Mandatory options and debugging
The `src` is the only mandatory option. The other in this section is useful for debugging or deciding what version of the target image is used.
| Parameter | Explained |
|----------------|----------------------------------------------|
| `src` | Source image to use, mandatory. `src=img.png` or with subdirectory `src=dir/img.png`. |
| `nc, no-cache` | Do not use the cached version, do all image processing and save a new image to cache. |
| `so, skip-original`| Skip using the original image, always process image, create and use a cached version of the original image. |
| `v, verbose` | Do verbose output and print out a log what happens. Good for debugging, analyzing the process and inspecting how the image is being processed. |
####Options for resizing image
These options are all affecting the dimensions used when resizing the image. Its used to define the area to use in the source image and the resulting dimensions for the target image.
| Parameter | Explained |
|----------------|----------------------------------------------|
| `h, height` | `h=200` sets the width to be to max 200px. `h=25%` sets the height to max 25% of its original height. |
| `w, width` | `w=200` sets the height to be max 200px. `w=100%` sets the width to max 100% of its original width. |
| `ar, aspect-ratio` | Control target aspect ratio. Use together with either height or width or alone to base calculations on original image dimensions. This setting is used to calculate the resulting dimension for the image. `w=160&aspect-ratio=1.6` results in a height of 100px. Use ar=!1.6 to inverse the ratio, useful when using portrat instead of landscape images. |
| `nr, no-ratio, stretch` | Do *not* keep aspect ratio when resizing and using both width & height constraints. Results in stretching the image, if needed, to fit in the resulting box. |
| `cf, crop-to-fit` | Set together with both `h` & `w` to make the image fit into dimensions, and crop out the rest of the image. |
| `a, area` | Define the area of the image to work with. Set `area=10,10,10,10` (top,right,bottom,left) to crop out the 10% of the outermost area. It works like an offset to define which part of the image you want to process. Its an alternative of using `crop`. |
| `c, crop` | Crops an area from the original image, set width, height, start_x and start_y to define the area to crop, for example `crop=100,100,10,10` (`crop=width,height,start_x,start_y`). Left top corner is 0, 0. You can use `left`, `right` or `center` when setting start_x. You may use `top`, `bottom` or `center` when setting start_y. |
####Processing of image before resizing
These options are executed *before* the image is resized.
| Parameter | Explained |
|----------------|----------------------------------------------|
| `s, scale` | Scale the image to a size proportional to a percentage of its original size, `scale=25` makes an image 25% of its original size and `size=200` doubles up the image size. Scale is applied before resizing and has no impact of the target width and height. |
####Processing of image after resizing
These options are executed *after* the image is resized.
| Parameter | Explained |
|----------------|----------------------------------------------|
| `sharpen` | Appy a filter that sharpens the image. |
| `emboss` | Appy a filter with an emboss effect. |
| `blur` | Appy a filter with a blur effect. |
| `f, filter` | Apply filter to image, `f=colorize,0,255,0,0` makes image more green. Supports all filters as defined in [PHP GD `imagefilter()`](http://php.net/manual/en/function.imagefilter.php). |
| `f0, f1-f9` | Same as `filter`, just add more filters. Applied in order `f`, `f0-f9`. |
####Saving image, affecting quality and filesize
Options for saving the target image.
| Parameter | Explained |
|----------------|----------------------------------------------|
| `q, quality` | Quality affects lossy compression and file size for JPEG images by setting the quality between 1-100, default is 60. Quality only affects JPEG. |
| `co, compress` | For PNG images it defines the compression algorithm, values can be 0-9, default is defined by PHP GD. Compress only affects PNG. |
| `p, palette` | Create a palette version of the image with up to 256 colors. |
| `sa, save-as` | Save resulting image as JPEG, PNG or GIF, for example `?src=river.png&save-as=gif`. |
Enjoy.
Mikael Roos (mos@dbwebb.se)
Revision history
----------------
ToDo.
* crop
* Pre-defined sizes.
-------------------------------------
v0.5.3 (2014-11-21)
* Support filenames of uppercase JPEG, JPG, PNG and GIF, as proposed in #37.
* Changing `CImage::output()` as proposed in #37.
* Adding security check that image filename is always below the path `image_path` as specified in `img_config.php` #37.
* Adding configuration item in `img_config.php` for setting valid characters in image filename.
* Moving `webroot/test*` into directory `webroot/test`.
* `webroot/check_system.php` now outputs if extension for exif is loaded.
* Broke API when `initDimensions()` split into two methods, new `initDimensions()` and `loadImageDetails()`.
* Added `autoRotate,`aro` to auto rotate image based on EXIF information.
* Added `bgColor,`bgc` to use as backgroundcolor when needing a filler color, for example rotate 45.
* Added `rotateBefore,`rb` to rotate image a certain angle before processing.
* Added `rotateAfter,`ra` to rotate image a certain angle after processing.
* Cleaned up code formatting, removed trailing spaces.
* Removed @ from opening images, better to display correct warning when failing #34, but put it back again.
* Setting gd.jpeg_ignore_warning to true as default #34.
* `webroot/check_system.php` now outputs version of PHP and GD.
* #32 correctly send 404 header when serving an error message.
* Trying to verify issue #29, but can not.
* Adding structure for testprograms together with, use `webroot/test_issue29.php` as sample.
* Improving code formatting.
* Moving parts of verbose output from img.php to CImage.php.
v0.5.2 (2014-04-01)
* Correcting issue #26 providing error message when not using postprocessing.
* Correcting issue #27 warning of default timezone.
* Removed default $config options in `img.php`, was not used, all configuration should be in `img_config.php`.
* Verified known bug - sharpen acts as blur in PHP 5.5.9 and 5.5.10 #28
v0.5.1 (2014-02-12)
* Display image in README-file.
* Create an empty `cache` directory as part of repo.
v0.5 (2014-02-12)
* Change constant name `CImage::PNG_QUALITY_DEFAULT` to `CImage::PNG_COMPRESSION_DEFAULT`.
* Split JPEG quality and PNG compression, `CImage->quality` and `CImage->compression`
* Changed `img.php` parameter name `d, deflate` to `co, compress`.
* Separating configuration issues from `img.php` to `img_config.php`.
* Format code according to PSR-2.
* Disabled post-processing JPEG and PNG as default.
* This version is supporting PHP 5.3, later versions will require 5.5 or later.
* Using GitHub issue tracking for feature requests and planning.
* Rewrote [the manual](http://dbwebb.se/opensource/cimage).
* Created directory `webroot` and moved some files there.
v0.4.1 (2014-01-27)
* Changed => to == on Modified-Since.
* Always send Last-Modified-Header.
* Added `htmlentities()` to verbose output.
* Fixed support for jpeg, not only jpg.
* Fixed crop whole image by setting crop=0,0,0,0
* Use negative values for crop width & height to base calulation on original width/height and withdraw selected amount.
* Correcting jpeg when setting quality.
* Removed obsolete reference to `$newName` in `CImage::__construct()` (issue 1).
v0.4 (2013-10-08)
* Improved support for pre-defined sizes.
* Adding grid column size as predefined size, c1-c24 for a 24 column grid. Configure in `img.php`.
* Corrected error on naming cache-files using subdir.
* Corrected calculation error on width & height for crop-to-fit.
* Adding effects for sharpen, emboss and blur through imageconvolution using matrixes.
* crop-to-fit, add parameter for offset x and y to enable to define which area is the, implemented as area.
* Support for resizing opaque images.
* Center of the image from which the crop is done. Improved usage of area to crop.
* Added support for % in width & height.
* Added aspect-ratio.
* Added scale.
* Quality for PNG images is now knows as deflate.
* Added palette to create images with max 256 colors.
* Added usage of all parameters to README.md
* Added documentation here http://dbwebb.se/opensource/cimage
* Adding `.gitignore`
* Re-adding `cache` directory
v0.3 (2012-10-02)
* Added crop. Can crop a area (`width`, `height`, `start_x`, `start_y`) from the original
image.
* Corrected to make the 304 Not Modified header work.
* Predefined sizes can be configured for width in `img.php`.
* Corrected to make crop work with width or height in combination with crop-to-fit.
v0.2 (2012-05-09)
* Implemented filters as in http://php.net/manual/en/function.imagefilter.php
* Changed `crop` to `crop_to_fit`, woks the same way.
* Changed arguments to method and sends them in array.
* Changed `crop` to `crop_to_fit`, works the same way.
* Changed arguments and sends them in array.
* Added quality-setting.
* Added testcases for above.
v0.1.1 (2012-04-27)
* Corrected calculation where both width and height were set.
@@ -42,4 +241,9 @@ v0.1.1 (2012-04-27)
v0.1 (2012-04-25)
* Initial release after rewriting some older code I had lying around.
* Initial release after rewriting some older code doing the same, but not that good and flexible.
<pre>
.
..: Copyright 2012-2014 by Mikael Roos (me@mikaelroos.se)
</pre>

1
cache/README.md vendored Normal file
View File

@@ -0,0 +1 @@
This directory must be writable by the webserver.

43
img.php
View File

@@ -1,43 +0,0 @@
<?php
/**
* Resize images on the fly using cache.
*
*/
error_reporting(-1);
set_time_limit(20);
// Append ending slash
$pathToImages = __DIR__.'/img/';
$pathToCache = __DIR__.'/cache/';
// Get input from querystring
$srcImage = isset($_GET['src']) ? $pathToImages . basename($_GET['src']) : null;
$newWidth = isset($_GET['width']) ? $_GET['width'] : (isset($_GET['w']) ? $_GET['w'] : null);
$newHeight = isset($_GET['height']) ? $_GET['height'] : (isset($_GET['h']) ? $_GET['h'] : null);
$keepRatio = isset($_GET['no-ratio']) ? false : true;
$cropToFit = isset($_GET['crop-to-fit']) ? true : false;
$crop = isset($_GET['crop']) ? $_GET['crop'] : (isset($_GET['c']) ? $_GET['c'] : null);
$quality = isset($_GET['quality']) ? $_GET['quality'] : (isset($_GET['q']) ? $_GET['q'] : 100);
// Add all filters to an array
$filters = array();
$filter = isset($_GET['filter']) ? $_GET['filter'] : (isset($_GET['f']) ? $_GET['f'] : null);
if($filter) { $filters[] = $filter; }
for($i=0; $i<10;$i++) {
$filter = isset($_GET["filter{$i}"]) ? $_GET["filter{$i}"] : (isset($_GET["f{$i}"]) ? $_GET["f{$i}"] : null);
if($filter) { $filters[] = $filter; }
}
// Do some sanity checks
!preg_match('/^[\w-\.]+$/', $srcImage) or die('Filename contains invalid characters.');
is_null($newWidth) or ($newWidth > 10 && $newWidth < 1000) or die('Width out of range.');
is_null($newHeight) or ($newHeight > 10 && $newHeight < 1000) or die('Hight out of range.');
$quality >= 0 and $quality <= 100 or die('Quality out of range');
// Create the image object
require(__DIR__.'/CImage.php');
$img = new CImage($srcImage, $pathToCache);
$img->ResizeAndOutput(array('newWidth'=>$newWidth, 'newHeight'=>$newHeight, 'keepRatio'=>$keepRatio,
'cropToFit'=>$cropToFit, 'quality'=>$quality,
'crop'=>$crop, 'filters'=>$filters,
));

15
webroot/check_system.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
echo 'Current PHP version: ' . phpversion() . '<br><br>';
echo 'Running on: ' . $_SERVER['SERVER_SOFTWARE'] . '<br><br>';
$no = extension_loaded('gd') ? null : 'NOT';
echo "Extension gd is $no loaded.<br>";
$no = extension_loaded('exif') ? null : 'NOT';
echo "Extension exif is $no loaded.<br>";
if (!$no) {
echo "<pre>", var_dump(gd_info()), "</pre>";
}

529
webroot/img.php Normal file
View File

@@ -0,0 +1,529 @@
<?php
/**
* Resize images on the fly using CImage, configuration is made in file named.
*
*/
/**
* Default configuration options, can be overridden in own config-file.
*
* @param string $msg to display.
*
* @return void
*/
function errorPage($msg)
{
header("HTTP/1.0 404 Not Found");
die('img.php say 404: ' . $msg);
}
/**
* Custom exception handler.
*/
set_exception_handler(function ($exception) {
errorPage("<p><b>img.php: Uncaught exception:</b> <p>" . $exception->getMessage() . "</p><pre>" . $exception->getTraceAsString(), "</pre>");
});
/**
* Get input from query string or return default value if not set.
*
* @param mixed $key as string or array of string values to look for in $_GET.
* @param mixed $default value to return when $key is not set in $_GET.
*
* @return mixed value from $_GET or default value.
*/
function get($key, $default = null)
{
if (is_array($key)) {
foreach ($key as $val) {
if (isset($_GET[$val])) {
return $_GET[$val];
}
}
} elseif (isset($_GET[$key])) {
return $_GET[$key];
}
return $default;
}
/**
* Get input from query string and set to $defined if defined or else $undefined.
*
* @param mixed $key as string or array of string values to look for in $_GET.
* @param mixed $defined value to return when $key is set in $_GET.
* @param mixed $undefined value to return when $key is not set in $_GET.
*
* @return mixed value as $defined or $undefined.
*/
function getDefined($key, $defined, $undefined)
{
return get($key) === null ? $undefined : $defined;
}
/**
* Log when verbose mode, when used without argument it returns the result.
*
* @param string $msg to log.
*
* @return void or array.
*/
function verbose($msg = null)
{
global $verbose;
static $log = array();
if (!$verbose) {
return;
}
if (is_null($msg)) {
return $log;
}
$log[] = $msg;
}
/**
* Get configuration options from file.
*/
$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
$config = require $configFile;
call_user_func($config['error_reporting']);
/**
* Set default timezone if not set or if its set in the config-file.
*/
if (isset($config['default_timezone'])) {
date_default_timezone_set($config['default_timezone']);
} else if (!ini_get('default_timezone')) {
date_default_timezone_set('UTC');
}
/**
* verbose, v - do a verbose dump of what happens
*/
$verbose = getDefined(array('verbose', 'v'), true, false);
/**
* src - the source image file.
*/
$srcImage = get('src')
or errorPage('Must set src-attribute.');
// Check for valid/invalid characters
preg_match($config['valid_filename'], $srcImage)
or errorPage('Filename contains invalid characters.');
// Check that the image is a file below the directory 'image_path'.
if ($config['image_path_constraint']) {
$pathToImage = realpath($config['image_path'] . $srcImage);
$imageDir = realpath($config['image_path']);
is_file($pathToImage)
or errorPage(
'Source image is not a valid file, check the filename and that a
matching file exists on the filesystem.'
);
substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0
or errorPage(
'Security constraint: Source image is not below the directory "image_path"
as specified in the config file img_config.php.'
);
}
verbose("src = $srcImage");
/**
* width, w - set target width, affecting the resulting image width, height and resize options
*/
$newWidth = get(array('width', 'w'));
// Check to replace predefined size
$sizes = call_user_func($config['size_constant']);
if (isset($sizes[$newWidth])) {
$newWidth = $sizes[$newWidth];
}
// Support width as % of original width
if ($newWidth[strlen($newWidth)-1] == '%') {
is_numeric(substr($newWidth, 0, -1))
or errorPage('Width % not numeric.');
} else {
is_null($newWidth)
or ($newWidth > 10 && $newWidth <= $config['max_width'])
or errorPage('Width out of range.');
}
verbose("new width = $newWidth");
/**
* height, h - set target height, affecting the resulting image width, height and resize options
*/
$newHeight = get(array('height', 'h'));
// Check to replace predefined size
if (isset($sizes[$newHeight])) {
$newHeight = $sizes[$newHeight];
}
// height
if ($newHeight[strlen($newHeight)-1] == '%') {
is_numeric(substr($newHeight, 0, -1))
or errorPage('Height % out of range.');
} else {
is_null($newHeight)
or ($newHeight > 10 && $newHeight <= $config['max_height'])
or errorPage('Hight out of range.');
}
verbose("new height = $newHeight");
/**
* aspect-ratio, ar - affecting the resulting image width, height and resize options
*/
$aspectRatio = get(array('aspect-ratio', 'ar'));
// Check to replace predefined aspect ratio
$aspectRatios = call_user_func($config['aspect_ratio_constant']);
$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false;
$aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio;
if (isset($aspectRatios[$aspectRatio])) {
$aspectRatio = $aspectRatios[$aspectRatio];
}
if ($negateAspectRatio) {
$aspectRatio = 1 / $aspectRatio;
}
is_null($aspectRatio)
or is_numeric($aspectRatio)
or errorPage('Aspect ratio out of range');
verbose("aspect ratio = $aspectRatio");
/**
* crop-to-fit, cf - affecting the resulting image width, height and resize options
*/
$cropToFit = getDefined(array('crop-to-fit', 'cf'), true, false);
verbose("crop to fit = $cropToFit");
/**
* no-ratio, nr, stretch - affecting the resulting image width, height and resize options
*/
$keepRatio = getDefined(array('no-ratio', 'nr', 'stretch'), false, true);
verbose("keep ratio = $keepRatio");
/**
* crop, c - affecting the resulting image width, height and resize options
*/
$crop = get(array('crop', 'c'));
verbose("crop = $crop");
/**
* area, a - affecting the resulting image width, height and resize options
*/
$area = get(array('area', 'a'));
verbose("area = $area");
/**
* skip-original, so - skip the original image and always process a new image
*/
$useOriginal = getDefined(array('save-as', 'sa'), false, true);
verbose("use original = $useOriginal");
/**
* no-cache, nc - skip the cached version and process and create a new version in cache.
*/
$useCache = getDefined(array('no-cache', 'nc'), false, true);
verbose("use cache = $useCache");
/**
* quality, q - set level of quality for jpeg images
*/
$quality = get(array('quality', 'q'));
is_null($quality)
or ($quality > 0 and $quality <= 100)
or errorPage('Quality out of range');
verbose("quality = $quality");
/**
* compress, co - what strategy to use when compressing png images
*/
$compress = get(array('compress', 'co'));
is_null($compress)
or ($compress > 0 and $compress <= 9)
or errorPage('Compress out of range');
verbose("compress = $compress");
/**
* save-as, sa - what type of image to save
*/
$saveAs = get(array('save-as', 'sa'));
verbose("save as = $saveAs");
/**
* scale, s - Processing option, scale up or down the image prior actual resize
*/
$scale = get(array('scale', 's'));
is_null($scale)
or ($scale >= 0 and $scale <= 400)
or errorPage('Scale out of range');
verbose("scale = $scale");
/**
* palette, p - Processing option, create a palette version of the image
*/
$palette = getDefined(array('palette', 'p'), true, false);
verbose("palette = $palette");
/**
* sharpen - Processing option, post filter for sharpen effect
*/
$sharpen = getDefined('sharpen', true, null);
verbose("sharpen = $sharpen");
/**
* emboss - Processing option, post filter for emboss effect
*/
$emboss = getDefined('emboss', true, null);
verbose("emboss = $emboss");
/**
* blur - Processing option, post filter for blur effect
*/
$blur = getDefined('blur', true, null);
verbose("blur = $blur");
/**
* rotate - Rotate the image with an angle, before processing
*/
/*
$rotate = get(array('rotate', 'r'));
is_null($rotate)
or ($rotate >= -360 and $rotate <= 360)
or errorPage('Rotate out of range');
verbose("rotate = $rotate");
*/
/**
* rotateBefore - Rotate the image with an angle, before processing
*/
$rotateBefore = get(array('rotateBefore', 'rb'));
is_null($rotateBefore)
or ($rotateBefore >= -360 and $rotateBefore <= 360)
or errorPage('RotateBefore out of range');
verbose("rotateBefore = $rotateBefore");
/**
* rotateAfter - Rotate the image with an angle, before processing
*/
$rotateAfter = get(array('rotateAfter', 'ra', 'rotate', 'r'));
is_null($rotateAfter)
or ($rotateAfter >= -360 and $rotateAfter <= 360)
or errorPage('RotateBefore out of range');
verbose("rotateAfter = $rotateAfter");
/**
* bgColor - Default background color to use
*/
$bgColor = hexdec(get(array('bgColor', 'bgc')));
is_null($bgColor)
or ($bgColor >= 0 and $bgColor <= hexdec("FFFFFF"))
or errorPage('Background color needs a hex value');
verbose("bgColor = $bgColor");
/**
* autoRotate - Auto rotate based on EXIF information
*/
$autoRotate = getDefined(array('autoRotate', 'aro'), true, false);
verbose("autoRotate = $autoRotate");
/**
* filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()
*/
$filters = array();
$filter = get(array('filter', 'f'));
if ($filter) {
$filters[] = $filter;
}
for ($i = 0; $i < 10; $i++) {
$filter = get(array("filter{$i}", "f{$i}"));
if ($filter) {
$filters[] = $filter;
}
}
verbose("filters = " . print_r($filters, 1));
/**
* Display image if verbose mode
*/
if ($verbose) {
$query = array();
parse_str($_SERVER['QUERY_STRING'], $query);
unset($query['verbose']);
unset($query['v']);
unset($query['nocache']);
unset($query['nc']);
$url1 = '?' . http_build_query($query);
echo <<<EOD
<a href=$url1><code>$url1</code></a><br>
<img src='{$url1}' />
EOD;
}
/**
* Create and output the image
*/
require $config['cimage_class'];
$img = new CImage();
$img->setVerbose($verbose)
->log("Incoming arguments: " . print_r(verbose(), 1))
->setSource($srcImage, $config['image_path'])
->setOptions(
array(
// Options for calculate dimensions
'newWidth' => $newWidth,
'newHeight' => $newHeight,
'aspectRatio' => $aspectRatio,
'keepRatio' => $keepRatio,
'cropToFit' => $cropToFit,
'crop' => $crop,
'area' => $area,
// Pre-processing, before resizing is done
'scale' => $scale,
'rotateBefore' => $rotateBefore,
// General processing options
'bgColor' => $bgColor,
// Post-processing, after resizing is done
'palette' => $palette,
'filters' => $filters,
'sharpen' => $sharpen,
'emboss' => $emboss,
'blur' => $blur,
'rotateAfter' => $rotateAfter,
'autoRotate' => $autoRotate,
)
)
->loadImageDetails()
->initDimensions()
->calculateNewWidthAndHeight()
->setSaveAsExtension($saveAs)
->setJpegQuality($quality)
->setPngCompression($compress)
->useOriginalIfPossible($useOriginal)
->generateFilename($config['cache_path'])
->useCacheIfPossible($useCache)
->load()
->preResize()
->resize()
->postResize()
->setPostProcessingOptions($config['postprocessing'])
->save()
->output();

BIN
webroot/img/ball24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
webroot/img/ball8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
webroot/img/car.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

View File

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
webroot/img/issue34/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
webroot/img/issue34/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
webroot/img/kodim04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 KiB

BIN
webroot/img/kodim07.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 KiB

BIN
webroot/img/kodim08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 KiB

BIN
webroot/img/kodim13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 KiB

BIN
webroot/img/kodim15.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 KiB

BIN
webroot/img/kodim22.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

BIN
webroot/img/kodim23.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 KiB

BIN
webroot/img/kodim24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 KiB

BIN
webroot/img/round24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
webroot/img/round8.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
webroot/img/round8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

BIN
webroot/img/wider.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
webroot/img/wider.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

122
webroot/img_config.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
/**
* Configuration for img.php, name the config file the same as your img.php and
* append _config. If you are testing out some in imgtest.php then label that
* config-file imgtest_config.php.
*
*/
return array(
/**
* Paths, where are all the stuff I should use?
* Append ending slash on directories.
*/
'cimage_class' => __DIR__.'/../CImage.php',
'image_path' => __DIR__.'/img/',
'cache_path' => __DIR__.'/../cache/',
/**
* Check that the imagefile is a file below 'image_path' using realpath().
*/
'image_path_constraint' => true,
/**
* A regexp for validating characters in the image filename.
*/
'valid_filename' => '#^[a-z0-9A-Z-/_\.]+$#',
/**
* Set default timezone, it defaults to UTC if not specified otherwise.
*
*/
//'default_timezone' => 'UTC',
/**
* Max image dimensions,
*
*/
'max_width' => 2000,
'max_height' => 2000,
/**
* Post processing of images using external tools, set to true or false
* and set command to be executed.
*/
'postprocessing' => array(
'png_filter' => false,
'png_filter_cmd' => '/usr/local/bin/optipng -q',
'png_deflate' => false,
'png_deflate_cmd' => '/usr/local/bin/pngout -q',
'jpeg_optimize' => false,
'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',
),
/**
* Predefined size constants.
*
*/
'size_constant' => function () {
// Set sizes to map constant to value, easier to use with width or height
$sizes = array(
'w1' => 613,
'w2' => 630,
);
// Add grid column width, useful for use as predefined size for width (or height).
$gridColumnWidth = 30;
$gridGutterWidth = 10;
$gridColumns = 24;
for ($i = 1; $i <= $gridColumns; $i++) {
$sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
}
return $sizes;
},
/**
* Predefined aspect ratios.
*
*/
'aspect_ratio_constant' => function () {
return array(
'3:1' => 3/1,
'3:2' => 3/2,
'4:3' => 4/3,
'8:5' => 8/5,
'16:10' => 16/10,
'16:9' => 16/9,
'golden' => 1.618,
);
},
/**
* Set error reporting to match development or production environment
*/
'error_reporting' => function () {
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
set_time_limit(20);
ini_set('gd.jpeg_ignore_warning', 1); // Ignore warning of corrupt jpegs
},
);

View File

@@ -5,29 +5,14 @@
</head>
<body>
<h1>Testing <code>CImage.php</code> through <code>img.php</code></h1>
<p>You can test any variation of resizing the images through <a href='img.php?src=wider.jpg&amp;w=200&amp;h=200'>img.php?src=wider.jpg&amp;w=200&amp;h=200</a> or <a href='img.php?src=higher.jpg&amp;w=200&amp;h=200'>img.php?src=higher.jpg&amp;w=200&amp;h=200</a></p>
<p>Supported arguments throught the querystring are:</p>
<ul>
<li>h, height: h=200 sets the height to 200px.
<li>w, width: w=200 sets the width to 200px.
<li>crop-to-fit: set together with both h & w to make the image fit in the box and crop out the rest.
<li>no-ratio: do not keep aspect ratio.
<li>q, quality: q=70 or quality=70 sets the image quality as value between 0 and 100, default is full quality/100.
<li>f, filter: apply filter to image, f=colorize,0,255,0,0 makes image greener. Supports all filters as defined in <a href='http://php.net/manual/en/function.imagefilter.php'><code>imagefilter()</code></a>
<li>f0-f9: same as f/filter, just add more filters. Applied in order f, f0-f9.
</ul>
<p>Supports <code>.jpg</code>, <code>.png</code> and <code>.gif</code>.</p>
<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>
<?php
$testcase = array(
array('text'=>'Original image', 'query'=>''),
array('text'=>'Crop out a rectangle of 100x100, start by position 200x200.', 'query'=>'&crop=100,100,200,200'),
array('text'=>'Crop out a full width rectangle with height of 200, start by position 0x100.', 'query'=>'&crop=0,200,0,100'),
array('text'=>'Max width 200.', 'query'=>'&w=200'),
array('text'=>'Max height 200.', 'query'=>'&h=200'),
array('text'=>'Max width 200 and max height 200.', 'query'=>'&w=200&h=200'),
@@ -51,6 +36,7 @@ $testcase = array(
array('text'=>'Filter: Smooth 2', 'query'=>'&w=200&h=200&f=smooth,2'),
array('text'=>'Filter: Pixelate 10,10', 'query'=>'&w=200&h=200&f=pixelate,10,10'),
array('text'=>'Multiple filter: Negate, Grayscale and Pixelate 10,10', 'query'=>'&w=200&h=200&&f=negate&f0=grayscale&f1=pixelate,10,10'),
array('text'=>'Crop with width & height and crop-to-fit with quality and filter', 'query'=>'&crop=100,100,100,100&w=200&h=200&crop-to-fit&q=70&f0=grayscale'),
);
?>
@@ -61,7 +47,7 @@ $testcase = array(
<tbody>
<?php
foreach($testcase as $key => $val) {
$url = "img.php?src=wider.jpg{$val['query']}";
$url = "../img.php?src=wider.jpg{$val['query']}";
echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
}
?>
@@ -75,7 +61,7 @@ foreach($testcase as $key => $val) {
<tbody>
<?php
foreach($testcase as $key => $val) {
$url = "img.php?src=higher.jpg{$val['query']}";
$url = "../img.php?src=higher.jpg{$val['query']}";
echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
}
?>

View File

@@ -0,0 +1,75 @@
<!doctype html>
<head>
<meta charset='utf-8'/>
<title>Testing img for issue 29</title>
<style>
body {background-color: #ccc;}
</style>
</head>
<body>
<h1>Testing issue 29</h1>
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
echo "<p>Version of PHP is: " . phpversion();
$imgphp = "../img.php?src=";
$images = array(
'issue29/400x265.jpg',
'issue29/400x268.jpg',
'issue29/400x300.jpg',
'issue29/465x304.jpg',
'issue29/640x273.jpg',
);
$testcase = array(
'&w=300&cf&q=80&nc',
'&w=75&h=75&cf&q=80&nc',
'&w=75&h=75&q=80',
);
?>
<h2>Images used in test</h2>
<p>The following images are used for this test.</p>
<?php foreach($images as $image) : ?>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php endforeach; ?>
<h2>Testcases used for each image</h2>
<p>The following testcases are used for each image.</p>
<?php foreach($testcase as $tc) : ?>
<code><?=$tc?></code><br>
<?php endforeach; ?>
<h2>Applying testcase for each image</h2>
<?php foreach($images as $image) : ?>
<h3><?=$image?></h3>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php foreach($testcase as $tc) : ?>
<h4><?=$tc?></h4>
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
<img src="<?=$imgphp . $image . $tc?>"></p>
<?php endforeach; ?>
<?php endforeach; ?>

View File

@@ -0,0 +1,77 @@
<!doctype html>
<head>
<meta charset='utf-8'/>
<title>Testing img for issue 36 - autoRotate</title>
<style>
body {background-color: #ccc;}
</style>
</head>
<body>
<h1>Testing issue 36 - autoRotate</h1>
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
$imgphp = "../img.php?src=";
$images = array(
'issue36/me-0.jpg',
'issue36/me-90.jpg',
'issue36/me-180.jpg',
'issue36/me-270.jpg',
'issue36/flower-0.jpg',
'issue36/flower-90.jpg',
'issue36/flower-180.jpg',
'issue36/flower-270.jpg',
);
$testcase = array(
'&aro&nc',
'&aro&nc&w=200',
'&aro&nc&h=200',
'&aro&nc&w=200&h=200&cf',
);
?>
<h2>Images used in test</h2>
<p>The following images are used for this test.</p>
<?php foreach($images as $image) : ?>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php endforeach; ?>
<h2>Testcases used for each image</h2>
<p>The following testcases are used for each image.</p>
<?php foreach($testcase as $tc) : ?>
<code><?=$tc?></code><br>
<?php endforeach; ?>
<h2>Applying testcase for each image</h2>
<?php foreach($images as $image) : ?>
<h3><?=$image?></h3>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php foreach($testcase as $tc) : ?>
<h4><?=$tc?></h4>
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
<img src="<?=$imgphp . $image . $tc?>"></p>
<?php endforeach; ?>
<?php endforeach; ?>

View File

@@ -0,0 +1,76 @@
<?php
$angle = 180;
?><!doctype html>
<head>
<meta charset='utf-8'/>
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
<style>
body {background-color: #ccc;}
</style>
</head>
<body>
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
$imgphp = "../img.php?src=";
$images = array(
'kodim08.png',
'kodim04.png',
);
$testcase = array(
"&rb=$angle&nc",
"&rb=$angle&nc&w=200",
"&rb=$angle&nc&h=200",
"&rb=$angle&nc&w=200&h=200&cf",
"&ra=$angle&nc",
"&ra=$angle&nc&w=200",
"&ra=$angle&nc&h=200",
"&ra=$angle&nc&w=200&h=200&cf",
);
?>
<h2>Images used in test</h2>
<p>The following images are used for this test.</p>
<?php foreach($images as $image) : ?>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php endforeach; ?>
<h2>Testcases used for each image</h2>
<p>The following testcases are used for each image.</p>
<?php foreach($testcase as $tc) : ?>
<code><?=$tc?></code><br>
<?php endforeach; ?>
<h2>Applying testcase for each image</h2>
<?php foreach($images as $image) : ?>
<h3><?=$image?></h3>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php foreach($testcase as $tc) : ?>
<h4><?=$tc?></h4>
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
<img src="<?=$imgphp . $image . $tc?>"></p>
<?php endforeach; ?>
<?php endforeach; ?>

View File

@@ -0,0 +1,76 @@
<?php
$angle = 270;
?><!doctype html>
<head>
<meta charset='utf-8'/>
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
<style>
body {background-color: #ccc;}
</style>
</head>
<body>
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
$imgphp = "../img.php?src=";
$images = array(
'kodim08.png',
'kodim04.png',
);
$testcase = array(
"&rb=$angle&nc",
"&rb=$angle&nc&w=200",
"&rb=$angle&nc&h=200",
"&rb=$angle&nc&w=200&h=200&cf",
"&ra=$angle&nc",
"&ra=$angle&nc&w=200",
"&ra=$angle&nc&h=200",
"&ra=$angle&nc&w=200&h=200&cf",
);
?>
<h2>Images used in test</h2>
<p>The following images are used for this test.</p>
<?php foreach($images as $image) : ?>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php endforeach; ?>
<h2>Testcases used for each image</h2>
<p>The following testcases are used for each image.</p>
<?php foreach($testcase as $tc) : ?>
<code><?=$tc?></code><br>
<?php endforeach; ?>
<h2>Applying testcase for each image</h2>
<?php foreach($images as $image) : ?>
<h3><?=$image?></h3>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php foreach($testcase as $tc) : ?>
<h4><?=$tc?></h4>
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
<img src="<?=$imgphp . $image . $tc?>"></p>
<?php endforeach; ?>
<?php endforeach; ?>

View File

@@ -0,0 +1,78 @@
<?php
$angle = 45;
?><!doctype html>
<head>
<meta charset='utf-8'/>
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
<style>
body {background-color: #ccc;}
</style>
</head>
<body>
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
$imgphp = "../img.php?src=";
$images = array(
'kodim08.png',
'kodim04.png',
);
$testcase = array(
"&rb=$angle&bgc=ffffff&nc",
"&rb=$angle&bgc=ffffff&nc&w=200",
"&rb=$angle&bgc=ffffff&nc&h=200",
"&rb=$angle&bgc=ffffff&nc&w=200&h=200&cf",
"&rb=$angle&bgc=ffffff&nc&w=200&h=200&cf&crop=200,200,center,center",
"&ra=$angle&bgc=ffffff&nc",
"&ra=$angle&bgc=ffffff&nc&w=200",
"&ra=$angle&bgc=ffffff&nc&h=200",
"&ra=$angle&bgc=ffffff&nc&w=200&h=200&cf",
"&ra=$angle&bgc=ffffff&nc&w=200&h=200&cf&crop=200,200,center,center",
);
?>
<h2>Images used in test</h2>
<p>The following images are used for this test.</p>
<?php foreach($images as $image) : ?>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php endforeach; ?>
<h2>Testcases used for each image</h2>
<p>The following testcases are used for each image.</p>
<?php foreach($testcase as $tc) : ?>
<code><?=$tc?></code><br>
<?php endforeach; ?>
<h2>Applying testcase for each image</h2>
<?php foreach($images as $image) : ?>
<h3><?=$image?></h3>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php foreach($testcase as $tc) : ?>
<h4><?=$tc?></h4>
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
<img src="<?=$imgphp . $image . $tc?>"></p>
<?php endforeach; ?>
<?php endforeach; ?>

View File

@@ -0,0 +1,76 @@
<?php
$angle = 90;
?><!doctype html>
<head>
<meta charset='utf-8'/>
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
<style>
body {background-color: #ccc;}
</style>
</head>
<body>
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
$imgphp = "../img.php?src=";
$images = array(
'kodim08.png',
'kodim04.png',
);
$testcase = array(
"&rb=$angle&nc",
"&rb=$angle&nc&w=200",
"&rb=$angle&nc&h=200",
"&rb=$angle&nc&w=200&h=200&cf",
"&ra=$angle&nc",
"&ra=$angle&nc&w=200",
"&ra=$angle&nc&h=200",
"&ra=$angle&nc&w=200&h=200&cf",
);
?>
<h2>Images used in test</h2>
<p>The following images are used for this test.</p>
<?php foreach($images as $image) : ?>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php endforeach; ?>
<h2>Testcases used for each image</h2>
<p>The following testcases are used for each image.</p>
<?php foreach($testcase as $tc) : ?>
<code><?=$tc?></code><br>
<?php endforeach; ?>
<h2>Applying testcase for each image</h2>
<?php foreach($images as $image) : ?>
<h3><?=$image?></h3>
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
<img src="<?=$imgphp . $image?>"></p>
<?php foreach($testcase as $tc) : ?>
<h4><?=$tc?></h4>
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
<img src="<?=$imgphp . $image . $tc?>"></p>
<?php endforeach; ?>
<?php endforeach; ?>