1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-14 12:05:08 +02:00

resize-strategies together with no upscale

This commit is contained in:
Mikael Roos
2015-12-06 01:24:30 +01:00
parent 679714422d
commit 5a09c38f5d
15 changed files with 733 additions and 431 deletions

View File

@@ -8,7 +8,7 @@
*
*/
$version = "v0.7.7* (2015-10-24)";
$version = "v0.8.0dev (2015-12-05)";
@@ -315,12 +315,9 @@ verbose("referer host = $refererHost");
* Get the source files.
*/
$autoloader = getConfig('autoloader', false);
$cimageClass = getConfig('cimage_class', false);
if ($autoloader) {
require $autoloader;
} elseif ($cimageClass) {
require $cimageClass;
}

View File

@@ -13,7 +13,8 @@ return array(
* Default values:
* mode: 'production'
*/
//'mode' => 'production', // 'development', 'strict'
//'mode' => 'production', // 'development', 'strict'
'mode' => 'development', // 'development', 'strict'
@@ -21,11 +22,9 @@ return array(
* Where are the sources for the classfiles.
*
* Default values:
* autoloader: null // used from v0.6.2
* cimage_class: null // used until v0.6.1
* autoloader: null
*/
'autoloader' => __DIR__ . '/../autoload.php',
//'cimage_class' => __DIR__ . '/../CImage.php',

View File

@@ -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 + "\nheigh: " + data.height + "\naspect-ratio: " + data.aspectRatio + "\npng-type: " + data.pngType;
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;
})
.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 {

View File

@@ -22,7 +22,8 @@ $images = array(
// For each image, apply these testcases
$nc = null; //"&nc"; //null; //&nc';
$nc = empty($_SERVER['QUERY_STRING']) ? "" : "&" . $_SERVER['QUERY_STRING'];
$testcase = array(
$nc . '&w=600',
$nc . '&w=600&no-upscale',
@@ -42,8 +43,8 @@ $testcase = array(
$nc . '&w=600&h=200&no-upscale&crop-to-fit',
$nc . '&w=300&h=400&crop-to-fit',
$nc . '&w=300&h=400&no-upscale&crop-to-fit',
$nc . '&w=600&h=400&fill-to-fit',
$nc . '&w=600&h=400&no-upscale&fill-to-fit',
$nc . '&w=600&h=500&fill-to-fit',
$nc . '&w=600&h=500&no-upscale&fill-to-fit',
/*
$nc . '&w=600&ar=1.6',
$nc . '&w=600&ar=1.6&no-upscale',

View File

@@ -0,0 +1,43 @@
<?php
// Include config for all testcases
include __DIR__ . "/config.php";
// The title of the test case
$title = "Testing resize landscape image";
// Provide a short description of the testcase.
$description = "Resize landscape image";
// Use these images in the test
$images = array(
'car.png',
);
// For each image, apply these testcases
$nc = empty($_SERVER['QUERY_STRING']) ? "" : "&" . $_SERVER['QUERY_STRING'];
$testcase = array(
$nc . '&w=500',
$nc . '&h=200',
$nc . '&w=500&h=500',
$nc . '&w=500&h=200',
$nc . '&w=500&h=200&crop-to-fit',
$nc . '&w=200&h=500&crop-to-fit',
$nc . '&w=500&h=200&fill-to-fit',
$nc . '&w=200&h=500&fill-to-fit',
$nc . '&w=500&h=200&stretch',
$nc . '&w=200&h=500&stretch',
);
// Apply testcases and present results
include __DIR__ . "/template.php";

View File

@@ -0,0 +1,43 @@
<?php
// Include config for all testcases
include __DIR__ . "/config.php";
// The title of the test case
$title = "Testing resize portrait image";
// Provide a short description of the testcase.
$description = "Resize portrait image";
// Use these images in the test
$images = array(
'kodim04.png',
);
// For each image, apply these testcases
$nc = empty($_SERVER['QUERY_STRING']) ? "" : "&" . $_SERVER['QUERY_STRING'];
$testcase = array(
$nc . '&w=500',
$nc . '&h=200',
$nc . '&w=500&h=500',
$nc . '&w=500&h=200',
$nc . '&w=500&h=200&crop-to-fit',
$nc . '&w=200&h=500&crop-to-fit',
$nc . '&w=500&h=200&fill-to-fit',
$nc . '&w=200&h=500&fill-to-fit',
$nc . '&w=500&h=200&stretch',
$nc . '&w=200&h=500&stretch',
);
// Apply testcases and present results
include __DIR__ . "/template.php";