2015-03-13 12:10:11 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 18:07:57 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-06-25 12:43:55 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
* @author Olivier Paroz <github@oparoz.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-03-13 12:10:11 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-13 12:10:11 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-03-16 14:57:15 +03:00
|
|
|
namespace OCP;
|
2015-03-13 12:10:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for basic image manipulation
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
interface IImage {
|
|
|
|
/**
|
|
|
|
* Determine whether the object contains an image resource.
|
|
|
|
*
|
|
|
|
* @return bool
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function valid();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the MIME type of the image or an empty string if no image is loaded.
|
|
|
|
*
|
|
|
|
* @return string
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function mimeType();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width of the image or -1 if no image is loaded.
|
|
|
|
*
|
|
|
|
* @return int
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function width();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the height of the image or -1 if no image is loaded.
|
|
|
|
*
|
|
|
|
* @return int
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function height();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width when the image orientation is top-left.
|
|
|
|
*
|
|
|
|
* @return int
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function widthTopLeft();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the height when the image orientation is top-left.
|
|
|
|
*
|
|
|
|
* @return int
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function heightTopLeft();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Outputs the image.
|
|
|
|
*
|
|
|
|
* @param string $mimeType
|
|
|
|
* @return bool
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function show($mimeType = null);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves the image.
|
|
|
|
*
|
|
|
|
* @param string $filePath
|
|
|
|
* @param string $mimeType
|
|
|
|
* @return bool
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function save($filePath = null, $mimeType = null);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return resource Returns the image resource in any.
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function resource();
|
|
|
|
|
2018-01-04 12:00:07 +03:00
|
|
|
/**
|
|
|
|
* @return string Returns the raw data mimetype
|
|
|
|
* @since 13.0.0
|
|
|
|
*/
|
|
|
|
public function dataMimeType();
|
|
|
|
|
2015-03-13 12:10:11 +03:00
|
|
|
/**
|
|
|
|
* @return string Returns the raw image data.
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function data();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* (I'm open for suggestions on better method name ;)
|
|
|
|
* Get the orientation based on EXIF data.
|
|
|
|
*
|
|
|
|
* @return int The orientation or -1 if no EXIF data is available.
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function getOrientation();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* (I'm open for suggestions on better method name ;)
|
|
|
|
* Fixes orientation based on EXIF data.
|
|
|
|
*
|
2015-04-16 18:00:08 +03:00
|
|
|
* @return bool
|
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function fixOrientation();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the image preserving ratio.
|
|
|
|
*
|
|
|
|
* @param integer $maxSize The maximum size of either the width or height.
|
|
|
|
* @return bool
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function resize($maxSize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $width
|
|
|
|
* @param int $height
|
|
|
|
* @return bool
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
2018-01-13 02:34:28 +03:00
|
|
|
public function preciseResize(int $width, int $height): bool;
|
2015-03-13 12:10:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Crops the image to the middle square. If the image is already square it just returns.
|
|
|
|
*
|
|
|
|
* @param int $size maximum size for the result (optional)
|
|
|
|
* @return bool for success or failure
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function centerCrop($size = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Crops the image from point $x$y with dimension $wx$h.
|
|
|
|
*
|
|
|
|
* @param int $x Horizontal position
|
|
|
|
* @param int $y Vertical position
|
|
|
|
* @param int $w Width
|
|
|
|
* @param int $h Height
|
|
|
|
* @return bool for success or failure
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
2018-01-13 02:34:28 +03:00
|
|
|
public function crop(int $x, int $y, int $w, int $h): bool;
|
2015-03-13 12:10:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the image to fit within a boundary while preserving ratio.
|
|
|
|
*
|
|
|
|
* @param integer $maxWidth
|
|
|
|
* @param integer $maxHeight
|
|
|
|
* @return bool
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-13 12:10:11 +03:00
|
|
|
*/
|
|
|
|
public function fitIn($maxWidth, $maxHeight);
|
2015-06-06 17:21:36 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shrinks the image to fit within a boundary while preserving ratio.
|
|
|
|
*
|
|
|
|
* @param integer $maxWidth
|
|
|
|
* @param integer $maxHeight
|
|
|
|
* @return bool
|
|
|
|
* @since 8.1.0
|
|
|
|
*/
|
|
|
|
public function scaleDownToFit($maxWidth, $maxHeight);
|
2020-02-16 04:34:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* create a copy of this image
|
|
|
|
*
|
|
|
|
* @return IImage
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function copy(): IImage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create a new cropped copy of this image
|
|
|
|
*
|
|
|
|
* @param int $x Horizontal position
|
|
|
|
* @param int $y Vertical position
|
|
|
|
* @param int $w Width
|
|
|
|
* @param int $h Height
|
|
|
|
* @return IImage
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function cropCopy(int $x, int $y, int $w, int $h): IImage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create a new resized copy of this image
|
|
|
|
*
|
|
|
|
* @param int $width
|
|
|
|
* @param int $height
|
|
|
|
* @return IImage
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function preciseResizeCopy(int $width, int $height): IImage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create a new resized copy of this image
|
|
|
|
*
|
|
|
|
* @param integer $maxSize The maximum size of either the width or height.
|
|
|
|
* @return IImage
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function resizeCopy(int $maxSize): IImage;
|
2015-03-13 12:10:11 +03:00
|
|
|
}
|