/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { if (!empty($this->configuration['random'])) { $degrees = abs((double) $this->configuration['degrees']); $this->configuration['degrees'] = rand(-$degrees, $degrees); } if (!$image->rotate($this->configuration['degrees'], $this->configuration['bgcolor'])) { $this->logger->error('Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; }
/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { // Convert short #FFF syntax to full #FFFFFF syntax. if (strlen($this->configuration['bgcolor']) == 4) { $c = $this->configuration['bgcolor']; $this->configuration['bgcolor'] = $c[0] . $c[1] . $c[1] . $c[2] . $c[2] . $c[3] . $c[3]; } // Convert #FFFFFF syntax to hexadecimal colors. if ($this->configuration['bgcolor'] != '') { $this->configuration['bgcolor'] = hexdec(str_replace('#', '0x', $this->configuration['bgcolor'])); } else { $this->configuration['bgcolor'] = NULL; } if (!empty($this->configuration['random'])) { $degrees = abs((double) $this->configuration['degrees']); $this->configuration['degrees'] = rand(-1 * $degrees, $degrees); } if (!$image->rotate($this->configuration['degrees'], $this->configuration['bgcolor'])) { watchdog('image', 'Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); return FALSE; } return TRUE; }