mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-05 07:37:37 +02:00
Adding option which defaults to 1. Set to 2 to get a twice as large image. Useful for Retina displays. Basically a shortcut to enlarge the image. #25
This commit is contained in:
19
CImage.php
19
CImage.php
@@ -174,6 +174,12 @@ class CImage
|
|||||||
private $newHeightOrig; // Save original value
|
private $newHeightOrig; // Save original value
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change target height & width when different ppi, ppi 2 means double image dimensions.
|
||||||
|
*/
|
||||||
|
private $ppi = 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array with details on how to crop, incoming as argument and calculated.
|
* Array with details on how to crop, incoming as argument and calculated.
|
||||||
*/
|
*/
|
||||||
@@ -353,6 +359,7 @@ class CImage
|
|||||||
|
|
||||||
// Output format
|
// Output format
|
||||||
'outputFormat' => null,
|
'outputFormat' => null,
|
||||||
|
'ppi' => 1,
|
||||||
|
|
||||||
// Options for saving
|
// Options for saving
|
||||||
//'quality' => null,
|
//'quality' => null,
|
||||||
@@ -521,6 +528,18 @@ class CImage
|
|||||||
$this->log("Setting new height based on aspect ratio to {$this->newHeight}");
|
$this->log("Setting new height based on aspect ratio to {$this->newHeight}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change width & height based on ppi
|
||||||
|
if ($this->ppi != 1) {
|
||||||
|
if (!is_null($this->newWidth)) {
|
||||||
|
$this->newWidth = round($this->newWidth * $this->ppi);
|
||||||
|
$this->log("Setting new width based on ppi={$this->ppi} - w={$this->newWidth}");
|
||||||
|
}
|
||||||
|
if (!is_null($this->newHeight)) {
|
||||||
|
$this->newHeight = round($this->newHeight * $this->ppi);
|
||||||
|
$this->log("Setting new height based on ppi={$this->ppi} - h={$this->newHeight}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check values to be within domain
|
// Check values to be within domain
|
||||||
is_null($this->newWidth)
|
is_null($this->newWidth)
|
||||||
or is_numeric($this->newWidth)
|
or is_numeric($this->newWidth)
|
||||||
|
@@ -133,6 +133,7 @@ Revision history
|
|||||||
|
|
||||||
v0.5.x (latest)
|
v0.5.x (latest)
|
||||||
|
|
||||||
|
* Adding option `ppi` which defaults to 1. Set to 2 to get a twice as large image. Useful for Retina displays. Basically a shortcut to enlarge the image.
|
||||||
* Adding utility `cache.bash` to ease gathering stats on cache usage. #21
|
* Adding utility `cache.bash` to ease gathering stats on cache usage. #21
|
||||||
* Cache-directory can now be readonly and serve all cached files, still failing when need to save files. #5
|
* Cache-directory can now be readonly and serve all cached files, still failing when need to save files. #5
|
||||||
* Cache now uses same file extension as original image #37.
|
* Cache now uses same file extension as original image #37.
|
||||||
|
@@ -463,6 +463,15 @@ verbose("json = $outputFormat");
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ppi - change to get larger image to easier support larger ppi, such as retina.
|
||||||
|
*/
|
||||||
|
$ppi = get('ppi', 1);
|
||||||
|
|
||||||
|
verbose("ppi = $ppi");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display image if verbose mode
|
* Display image if verbose mode
|
||||||
*/
|
*/
|
||||||
@@ -522,6 +531,7 @@ $img->setVerbose($verbose)
|
|||||||
|
|
||||||
// Output format
|
// Output format
|
||||||
'outputFormat' => $outputFormat,
|
'outputFormat' => $outputFormat,
|
||||||
|
'ppi' => $ppi,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->loadImageDetails()
|
->loadImageDetails()
|
||||||
|
Reference in New Issue
Block a user