<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
}
if ($this->isImagick()) {
- /* Clean it */
- $this->image = $this->image->deconstructImages();
- return $this->image;
+ try {
+ /* Clean it */
+ $this->image = $this->image->deconstructImages();
+ return $this->image;
+ } catch (Exception $e) {
+ return false;
+ }
}
return $this->image;
}
do {
// FIXME - implement horizontal bias for scaling as in following GD functions
// to allow very tall images to be constrained only horizontally.
- $this->image->scaleImage($dest_width, $dest_height);
+ try {
+ $this->image->scaleImage($dest_width, $dest_height);
+ } catch (Exception $e) {
+ // Imagick couldn't use the data
+ return false;
+ }
} while ($this->image->nextImage());
// These may not be necessary anymore
return true;
}
+ /**
+ * Convert a GIF to a PNG to make it static
+ */
+ public function toStatic()
+ {
+ if ($this->type != 'image/gif') {
+ return;
+ }
+
+ if ($this->isImagick()) {
+ $this->type == 'image/png';
+ $this->image->setFormat('png');
+ }
+ }
+
/**
* @param integer $max maximum
* @param integer $x x coordinate
$string = $this->asString();
- $stamp1 = microtime(true);
+ DI::profiler()->stopRecording('file');
file_put_contents($path, $string);
- DI::profiler()->saveTimestamp($stamp1, "file");
+ DI::profiler()->stopRecording();
}
/**
}
if ($this->isImagick()) {
- /* Clean it */
- $this->image = $this->image->deconstructImages();
- $string = $this->image->getImagesBlob();
- return $string;
+ try {
+ /* Clean it */
+ $this->image = $this->image->deconstructImages();
+ $string = $this->image->getImagesBlob();
+ return $string;
+ } catch (Exception $e) {
+ return false;
+ }
}
ob_start();