use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\DBA;
-use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Util\Network;
use Exception;
*/
class Image
{
+ /** @var Imagick|resource */
private $image;
/*
/**
* @brief Constructor
- * @param object $data data
+ * @param string $data
* @param boolean $type optional, default null
- * @return object
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public function __construct($data, $type = null)
{
}
/**
- * @param object $data data
+ * @param string $data data
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
private function loadData($data)
{
$width = $this->getWidth();
$height = $this->getHeight();
- $dest_width = $dest_height = 0;
-
if ((! $width)|| (! $height)) {
return false;
}
$width = $this->getWidth();
$height = $this->getHeight();
- $dest_width = $dest_height = 0;
-
if ((!$width)|| (!$height)) {
return false;
}
/**
* @param string $path file path
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function saveToFilePath($path)
{
* $data = (string) $Image;
*
* @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __toString() {
return $this->asString();
/**
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function asString()
{
return $string;
}
- $quality = false;
-
ob_start();
// Enable interlacing
*
* @param string $filename Image filename
* @param boolean $fromcurl Check Content-Type header from curl request
- * @param string $header passed headers to take into account
+ * @param string $header passed headers to take into account
*
* @return object
+ * @throws \ImagickException
*/
public static function guessType($filename, $fromcurl = false, $header = '')
{
Logger::log('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), Logger::DEBUG);
$type = null;
if ($fromcurl) {
- $a = \get_app();
$headers=[];
$h = explode("\n", $header);
foreach ($h as $l) {
/**
* @param string $url url
* @return object
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getInfoFromURL($url)
{
*/
public static function getScalingDimensions($width, $height, $max)
{
- $dest_width = $dest_height = 0;
-
if ((!$width) || (!$height)) {
return false;
}
/**
* @brief This function is used by the fromgplus addon
- * @param object $a App
+ * @param App $a App
* @param integer $uid user id
* @param string $imagedata optional, default empty
* @param string $url optional, default empty
* @return array
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
*/
public static function storePhoto(App $a, $uid, $imagedata = "", $url = "")
{
/// @TODO
/// $default_cid = $r[0]['id'];
- /// $community_page = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
+ /// $community_page = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if ((strlen($imagedata) == 0) && ($url == "")) {
Logger::log("No image data and no url provided", Logger::DEBUG);
$hash = Photo::newResource();
- $smallest = 0;
-
// Pictures are always public by now
//$defperm = '<'.$default_cid.'>';
$defperm = "";