mirror of
https://github.com/mosbth/cimage.git
synced 2025-09-02 12:12:49 +02:00
Added option fill-to-fit, ff. Fix #38.
This commit is contained in:
102
webroot/img.php
102
webroot/img.php
@@ -116,6 +116,23 @@ if (isset($config['default_timezone'])) {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* verbose, v - do a verbose dump of what happens
|
||||
*/
|
||||
$verbose = getDefined(array('verbose', 'v'), true, false);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the class for the image.
|
||||
*/
|
||||
require $config['cimage_class'];
|
||||
|
||||
$img = new CImage();
|
||||
$img->setVerbose($verbose);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* shortcut, sc - extend arguments with a constant value, defined
|
||||
* in config-file.
|
||||
@@ -135,13 +152,6 @@ if (isset($shortcut)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* verbose, v - do a verbose dump of what happens
|
||||
*/
|
||||
$verbose = getDefined(array('verbose', 'v'), true, false);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* src - the source image file.
|
||||
*/
|
||||
@@ -262,6 +272,45 @@ verbose("crop to fit = $cropToFit");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set default background color from config file.
|
||||
*/
|
||||
if (isset($config['background_color'])) {
|
||||
$img->setDefaultBackgroundColor($config['background_color']);
|
||||
verbose("Using default background_color = {$config['background_color']}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* bgColor - Default background color to use
|
||||
*/
|
||||
$bgColor = get(array('bgColor', 'bgc'), null);
|
||||
|
||||
verbose("bgColor = $bgColor");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* fill-to-fit, ff - affecting the resulting image width, height and resize options
|
||||
*/
|
||||
$fillToFit = get(array('fill-to-fit', 'ff'), null);
|
||||
|
||||
verbose("fill-to-fit = $fillToFit");
|
||||
|
||||
if ($fillToFit !== null) {
|
||||
|
||||
if (!empty($fillToFit)) {
|
||||
$bgColor = $fillToFit;
|
||||
verbose("fillToFit changed bgColor to = $bgColor");
|
||||
}
|
||||
|
||||
$fillToFit = true;
|
||||
verbose("fill-to-fit (fixed) = $fillToFit");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* no-ratio, nr, stretch - affecting the resulting image width, height and resize options
|
||||
*/
|
||||
@@ -392,20 +441,6 @@ 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
|
||||
*/
|
||||
@@ -432,19 +467,6 @@ 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
|
||||
*/
|
||||
@@ -492,16 +514,6 @@ verbose("dpr = $dpr");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the class for the image.
|
||||
*/
|
||||
require $config['cimage_class'];
|
||||
|
||||
$img = new CImage();
|
||||
$img->setVerbose($verbose);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* convolve - image convolution as in http://php.net/manual/en/function.imageconvolution.php
|
||||
*/
|
||||
@@ -540,7 +552,6 @@ EOD;
|
||||
/**
|
||||
* Load, process and output the image
|
||||
*/
|
||||
|
||||
$img->log("Incoming arguments: " . print_r(verbose(), 1))
|
||||
->setSource($srcImage, $config['image_path'])
|
||||
->setOptions(
|
||||
@@ -551,6 +562,7 @@ $img->log("Incoming arguments: " . print_r(verbose(), 1))
|
||||
'aspectRatio' => $aspectRatio,
|
||||
'keepRatio' => $keepRatio,
|
||||
'cropToFit' => $cropToFit,
|
||||
'fillToFit' => $fillToFit,
|
||||
'crop' => $crop,
|
||||
'area' => $area,
|
||||
|
||||
|
Reference in New Issue
Block a user