Skip to content

Commit

Permalink
Support new Image InterventionBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
axllent committed Jul 5, 2017
1 parent 2ee1898 commit 5ed6311
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ScaledUploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function onAfterLoadIntoFile($file)

private function ScaleUploadedImage($file)
{

$backend = $file->getImageBackend();

/* temporary location for image manipulation */
$tmp_image = TEMP_FOLDER .'/resampled-' . mt_rand(100000, 999999) . '.' . $file->getExtension();

Expand All @@ -68,22 +71,20 @@ private function ScaleUploadedImage($file)
// write to tmp file
@file_put_contents($tmp_image, $tmp_contents);

$gd = new GDBackend();

$gd->loadFrom($tmp_image);
$backend->loadFrom($tmp_image);

if ($gd->getImageResource()) {
if ($backend->getImageResource()) {
$modified = false;

/* Clone original */
$transformed = $gd;
$transformed = $backend;

/* If rotation allowed & JPG, test to see if orientation needs switching */
if ($this->auto_rotate && preg_match('/jpe?g/i', $file->getExtension())) {
$switch_orientation = $this->exifRotation($tmp_image);
if ($switch_orientation) {
$modified = true;
$transformed = $transformed->rotate($switch_orientation);
$transformed->setImageResource($transformed->getImageResource()->orientate());
}
}

Expand Down

0 comments on commit 5ed6311

Please sign in to comment.