* @return bool
*/
public function valid() {
- if (is_resource($this->resource)) {
- return true;
- }
- if (is_object($this->resource) && get_class($this->resource) === \GdImage::class) {
+ if ((is_resource($this->resource) && get_resource_type($this->resource) === 'gd') ||
+ (is_object($this->resource) && get_class($this->resource) === \GdImage::class)) {
return true;
}
*/
public function fixOrientation() {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$o = $this->getOrientation();
*/
public function resize($maxSize) {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$result = $this->resizeNew($maxSize);
*/
private function resizeNew($maxSize) {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$widthOrig = imagesx($this->resource);
*/
public function preciseResize(int $width, int $height): bool {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$result = $this->preciseResizeNew($width, $height);
return false;
}
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$widthOrig = imagesx($this->resource);
$heightOrig = imagesy($this->resource);
$process = imagecreatetruecolor($width, $height);
if ($process === false) {
- $this->logger->error(__METHOD__ . '(): Error creating true color image', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): Error creating true color image', ['app' => 'core']);
return false;
}
$res = imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
if ($res === false) {
- $this->logger->error(__METHOD__ . '(): Error re-sampling process image', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): Error re-sampling process image', ['app' => 'core']);
imagedestroy($process);
return false;
}
*/
public function centerCrop($size = 0) {
if (!$this->valid()) {
- $this->logger->error('OC_Image->centerCrop, No image loaded', ['app' => 'core']);
+ $this->logger->debug('OC_Image->centerCrop, No image loaded', ['app' => 'core']);
return false;
}
$widthOrig = imagesx($this->resource);
}
$process = imagecreatetruecolor($targetWidth, $targetHeight);
if ($process === false) {
- $this->logger->error('OC_Image->centerCrop, Error creating true color image', ['app' => 'core']);
+ $this->logger->debug('OC_Image->centerCrop, Error creating true color image', ['app' => 'core']);
return false;
}
imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
if ($process === false) {
- $this->logger->error('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, ['app' => 'core']);
+ $this->logger->debug('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, ['app' => 'core']);
return false;
}
imagedestroy($this->resource);
*/
public function crop(int $x, int $y, int $w, int $h): bool {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$result = $this->cropNew($x, $y, $w, $h);
*/
public function cropNew(int $x, int $y, int $w, int $h) {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$process = imagecreatetruecolor($w, $h);
if ($process === false) {
- $this->logger->error(__METHOD__ . '(): Error creating true color image', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): Error creating true color image', ['app' => 'core']);
return false;
}
imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $w, $h, $w, $h);
if ($process === false) {
- $this->logger->error(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, ['app' => 'core']);
return false;
}
return $process;
*/
public function fitIn($maxWidth, $maxHeight) {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$widthOrig = imagesx($this->resource);
*/
public function scaleDownToFit($maxWidth, $maxHeight) {
if (!$this->valid()) {
- $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
+ $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
}
$widthOrig = imagesx($this->resource);