mirror of
https://github.com/mosbth/cimage.git
synced 2025-07-25 10:41:35 +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
@@ -173,6 +173,12 @@ class CImage
|
||||
private $newHeight;
|
||||
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.
|
||||
@@ -353,6 +359,7 @@ class CImage
|
||||
|
||||
// Output format
|
||||
'outputFormat' => null,
|
||||
'ppi' => 1,
|
||||
|
||||
// Options for saving
|
||||
//'quality' => null,
|
||||
@@ -521,6 +528,18 @@ class CImage
|
||||
$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
|
||||
is_null($this->newWidth)
|
||||
or is_numeric($this->newWidth)
|
||||
|
@@ -133,6 +133,7 @@ Revision history
|
||||
|
||||
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
|
||||
* 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.
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -522,6 +531,7 @@ $img->setVerbose($verbose)
|
||||
|
||||
// Output format
|
||||
'outputFormat' => $outputFormat,
|
||||
'ppi' => $ppi,
|
||||
)
|
||||
)
|
||||
->loadImageDetails()
|
||||
|
Reference in New Issue
Block a user