diff --git a/test/Tests.txt b/test/Tests.txt index e333787..fc14fef 100644 --- a/test/Tests.txt +++ b/test/Tests.txt @@ -1,3 +1,7 @@ # Tests to be done Use resize fill-to-fit, crop-to-fit, stretch without width and height should result in image having original width and height. + +## Integration tests + +Checkout a version using composer and execute all tests, prefarably on cimage.se. diff --git a/webroot/img/apple.jpg b/webroot/img/apple.jpg new file mode 100644 index 0000000..efdf810 Binary files /dev/null and b/webroot/img/apple.jpg differ diff --git a/webroot/img_config.php b/webroot/img_config.php index 36066e2..ace5308 100644 --- a/webroot/img_config.php +++ b/webroot/img_config.php @@ -10,6 +10,15 @@ return [ /** * Set mode as 'strict', 'production' or 'development'. * + * development: Development mode with verbose error reporting. Option + * &verbose and &status enabled. + * production: Production mode logs all errors to file, giving server + * error 500 for bad usage. Option &verbose and &status + * disabled. + * strict: Strict mode logs few errors to file, giving server error + * 500 for bad usage. Stripped from comments and spaces. + * Option &verbose and &status disabled. + * * Default values: * mode: 'production' */ @@ -106,6 +115,20 @@ return [ + /** + * Use backup image if src-image is not found on disk. The backup image + * is only available for local images and based on wether the original + * image is found on disk or not. The backup image must be a local image + * or the dummy image. + * + * Default value: + * src_alt: null //disabled by default + */ + //'src_alt' => 'car.png', + //'src_alt' => 'dummy', + + + /** * A regexp for validating characters in the image or alias filename. * @@ -123,18 +146,20 @@ return [ * when saving images. * * Default value: - * jpg_quality: null, integer between 0-100 - * png_compression: null, integer between 0-9 + * jpg_quality: null, integer between 0-100, + * default is 60 + * png_compression: null, integer between 0-9, + * default is -1 (PHP GD decides) */ - //'jpg_quality' => 75, - //'png_compression' => 1, + //'jpg_quality' => 60, + //'png_compression' => -1, /** - * Convert the image to srgb before processing. Saves the converted + * Convert the image to sRGB before processing. Saves the converted * image in a cache subdir 'srgb'. This option is default false but can - * be changed to default true to do this conversion for all images. + * be changed to default true to always do conversion for all images. * This option requires PHP extension imagick and will silently fail * if that is not installed. * @@ -273,7 +298,7 @@ return [ * jpeg_optimize_cmd: '/usr/local/bin/jpegtran -copy none -optimize' */ /* - 'postprocessing' => array( + 'postprocessing' => [ 'png_filter' => false, 'png_filter_cmd' => '/usr/local/bin/optipng -q', @@ -282,7 +307,7 @@ return [ 'jpeg_optimize' => false, 'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize', - ), + ], */ @@ -399,7 +424,7 @@ return [ /** - * default options for ascii image. + * Default options for ascii image. * * Default values as specified below in the array. * ascii-options: diff --git a/webroot/js/cimage.js b/webroot/js/cimage.js index e3f7d43..ed8a8c4 100644 --- a/webroot/js/cimage.js +++ b/webroot/js/cimage.js @@ -31,7 +31,7 @@ window.CImage = (function() { stack = document.getElementById("stack"), bg = document.getElementById("bg"), permalink = document.getElementById("permalink"); - + link = "?"; link += "input1=" + encodeURIComponent(input1.value) + "&"; link += "input2=" + encodeURIComponent(input2.value) + "&"; @@ -59,9 +59,9 @@ window.CImage = (function() { button = document.getElementById("button" + id); area = document.getElementById("area" + id); deck = document.getElementById("deck" + id); - + updatePermaLink(); - + if (this.value == "") { // Clear image if input is cleared button.setAttribute("disabled", "disabled"); @@ -75,7 +75,7 @@ window.CImage = (function() { area.classList.remove("hidden"); $.getJSON(this.value + "&json", function(data) { - json.innerHTML = "filename: " + data.filename + "\ncolors: " + data.colors + "\nsize: " + data.size + "\nwidth: " + data.width + "\nheight: " + data.height + "\naspect-ratio: " + data.aspectRatio + "\npng-type: " + data.pngType; + json.innerHTML = "filename: " + data.filename + "\ncolors: " + data.colors + "\nsize: " + data.size + "\nwidth: " + data.width + "\nheigh: " + data.height + "\naspect-ratio: " + data.aspectRatio + "\npng-type: " + data.pngType; }) .fail(function() { json.innerHTML = "Details not available." @@ -94,7 +94,7 @@ window.CImage = (function() { /** * Init the compare page with details. */ - function compareInit(options) + function compareInit(options) { var elements, id, onTop, myEvent, input1 = document.getElementById("input1"), @@ -118,7 +118,7 @@ window.CImage = (function() { // Toggle json details.addEventListener("change", function() { var elements = document.querySelectorAll(".json"); - + forEach(elements, function (index, element) { element.classList.toggle("hidden"); }); @@ -128,7 +128,7 @@ window.CImage = (function() { element.classList.toggle("hidden"); } */ - + updatePermaLink(); console.log("View JSON"); }); @@ -215,7 +215,7 @@ window.CImage = (function() { element.addEventListener("click", function() { var id = this.dataset.id, area = document.getElementById("area" + id); - + area.classList.toggle("top"); onTop.classList.toggle("top"); onTop = area; @@ -239,7 +239,7 @@ window.CImage = (function() { compareLoadImage.call(input6); console.log(options); - } + } return {