Skip to content

Commit

Permalink
Testing that file exists and file size
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregwar committed Oct 25, 2018
1 parent c506d57 commit 25fbb91
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Adapter/GD.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,23 +586,35 @@ public function saveJpeg($file, $quality)
*/
protected function openJpeg($file)
{
$this->resource = @imagecreatefromjpeg($file);
if (file_exists($file) && filesize($file)) {
$this->resource = @imagecreatefromjpeg($file);
} else {
$this->resource = false;
}
}

/**
* Try to open the file using gif.
*/
protected function openGif($file)
{
$this->resource = @imagecreatefromgif($file);
if (file_exists($file) && filesize($file)) {
$this->resource = @imagecreatefromgif($file);
} else {
$this->resource = false;
}
}

/**
* Try to open the file using PNG.
*/
protected function openPng($file)
{
$this->resource = @imagecreatefrompng($file);
if (file_exists($file) && filesize($file)) {
$this->resource = @imagecreatefrompng($file);
} else {
$this->resource = false;
}
}

/**
Expand Down

0 comments on commit 25fbb91

Please sign in to comment.