diff --git a/Image.php b/Image.php index 5939199..86efb7a 100644 --- a/Image.php +++ b/Image.php @@ -667,7 +667,25 @@ public function inline($type = 'jpg', $quality = 80) return 'data:image/'.$mime.';base64,'.base64_encode(file_get_contents($this->cacheFile($type, $quality, true))); } + + /** + * Increase or Decrease the size of image to given percent + */ + public function percentReszie($percent) + { + $pWidth = ($this->width() * abs((int)$percent)) / 100; + $pHeight = ($this->height() * abs((int)$percent)) / 100; + if ($percent < 0) { + $nWidth = $this->width() - $pWidth; + $nHeight = $this->height() - $pHeight; + } else { + $nWidth = $this->width() + $pWidth; + $nHeight = $this->height() + $pHeight; + } + return $this->scaleResize($nWidth, $nHeight); + } + /** * Creates an instance, usefull for one-line chaining */