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

Commit

Permalink
Update Image.php
Browse files Browse the repository at this point in the history
Add documentation
  • Loading branch information
jbelien committed Jan 9, 2018
1 parent aa7fc34 commit 8d4a67b
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/Image.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,63 @@
<?php

declare(strict_types=1);

/**
* This file is part of the GEO-6 package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license GNU General Public License v3.0
*/

namespace Geo6\Image;

use ErrorException;

/**
* @author Jonathan Beliën <jbe@geo6.be>
*/
class Image
{
/**
* @var string|null
*/
private $file = null;

/**
* @var int
*/
private $height;

/**
* @var resource
*/
private $resource;

/**
* @var int|null
*/
private $type = null;

/**
* @var string|null
*/
private $sourceFile = null;

/**
* @var string|null
*/
private $tempnam = null;

/**
* @var int
*/
private $width;

/**
* @param int $width
* @param int $height
*/
public function __construct(int $width, int $height)
{
$this->height = $height;
Expand All @@ -30,6 +74,14 @@ public function __destruct()
}
}

/**
* @param string $file Path to your file.
*
* @throws ErrorException if the file does not exists or is not readable.
* @throws ErrorException if the type of the file is not supported.
*
* @return Image
*/
public static function createFromFile(string $file)
{
if (file_exists($file) && is_readable($file)) {
Expand Down Expand Up @@ -71,6 +123,11 @@ public static function createFromFile(string $file)
return $new;
}

/**
* @param int $maxSize Mix width and height (in pixels).
*
* @return Image
*/
public function thumbnail(int $maxSize)
{
if (max($this->width, $this->height) > $maxSize) {
Expand All @@ -94,6 +151,8 @@ public function thumbnail(int $maxSize)
}

/**
* @return Image
*
* @link http://owl.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
* @link http://sylvana.net/jpegcrop/exif_orientation.html
*/
Expand Down Expand Up @@ -148,6 +207,11 @@ public function EXIFRotate()
return $rotated;
}

/**
* @param string $file Path (including filename) where you want to save your image.
*
* @return bool
*/
public function save(string $file)
{
if (file_exists($file) && is_dir($file)) {
Expand Down Expand Up @@ -190,6 +254,9 @@ public function save(string $file)
return $result;
}

/**
*
*/
public function display()
{
if (is_null($this->file)) {
Expand Down

0 comments on commit 8d4a67b

Please sign in to comment.