Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
really...
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Fonseca committed Dec 29, 2014
1 parent e9dc485 commit 00b1c0c
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/Joselfonseca/ImageManager/ImageRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,49 @@ class ImageRender {
protected $bgcolor;
protected $position;


protected function resize() {
if (empty($this->canvas)) {
$this->resizeNormal();
} else {
$this->resizeCanvas();
}
}

// This is Dirty, will come back to it later
protected function resizeNormal() {
if (empty($this->path)) {
$this->image = \Image::cache(function($image) {
if (!empty($this->width) && empty($this->height)) {
return $image->canvas(800, 800, $this->bgcolor)->resize($this->width, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$constraint->aspectRatio();
$constraint->upsize();
});
} elseif (empty($this->width) && !empty($this->height)) {
return $image->canvas(800, 800, $this->bgcolor)->resize(null, $this->height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
} else{
$constraint->aspectRatio();
$constraint->upsize();
});
} elseif (!empty($this->width) && !empty($this->height)) {
return $image->canvas(800, 800, $this->bgcolor)->resize($this->width, $this->height);
} else {
return $image->canvas(800, 800, $this->bgcolor);
}
}, 10, true);
} else {
$this->image = \Image::cache(function($image) {
if (!empty($this->width) && empty($this->height)) {
return $image->make($this->destination . '/' . $this->path)->resize($this->width, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$constraint->aspectRatio();
$constraint->upsize();
});
} elseif (empty($this->width) && !empty($this->height)) {
return $image->make($this->destination . '/' . $this->path)->resize(null, $this->height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
} else{
$constraint->aspectRatio();
$constraint->upsize();
});
} elseif (!empty($this->width) && !empty($this->height)) {
return $image->make($this->destination . '/' . $this->path)->resize($this->width, $this->height);
} else {
return $image->make($this->destination . '/' . $this->path);
}
}, 10, true);
Expand Down

0 comments on commit 00b1c0c

Please sign in to comment.