/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { if (!$image->desaturate()) { watchdog('image', 'Image desaturate 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; }
/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { if (!$image->resize($this->configuration['width'], $this->configuration['height'])) { $this->logger->error('Image resize 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) { if (!$image->scaleAndCrop($this->configuration['width'], $this->configuration['height'])) { watchdog('image', 'Image scale and crop 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; }
/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { if (!$image->convert($this->configuration['extension'])) { $this->logger->error('Image convert failed using the %toolkit toolkit on %path (%mimetype)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType())); return FALSE; } return TRUE; }
/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { // First, attempt to resize the image. $resize_data = self::calculateResizeData($image->getWidth(), $image->getHeight(), $this->configuration['width'], $this->configuration['height']); if (!$image->resize($resize_data['width'], $resize_data['height'])) { watchdog('image', 'Focal point scale and crop failed while resizing 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; } // Next, attempt to crop the image. $focal_point = FocalPoint::getFromURI($image->getSource()); $crop_data = self::calculateCropData($focal_point, $image->getWidth(), $image->getHeight(), $this->configuration['width'], $this->configuration['height']); if (!$image->crop($crop_data['x'], $crop_data['y'], $crop_data['width'], $crop_data['height'])) { watchdog('image', 'Focal point scale and crop failed while scaling and cropping 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; }
/** * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { list($x, $y) = explode('-', $this->configuration['anchor']); $x = image_filter_keyword($x, $image->getWidth(), $this->configuration['width']); $y = image_filter_keyword($y, $image->getHeight(), $this->configuration['height']); if (!$image->crop($x, $y, $this->configuration['width'], $this->configuration['height'])) { $this->logger->error('Image crop 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) { 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) { $path = $image->getSource(); $entity_manager = \Drupal::entityManager(); $files = $entity_manager->getStorage('file')->loadByProperties(array('uri' => $path)); $file = NULL; if (count($files)) { $file = reset($files); $info = imagefield_crop_get_file_info($file->id()); if (!$info) { return TRUE; } if (!$image->crop($info['x'], $info['y'], $info['width'], $info['height'])) { $this->logger->error('Image crop 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; }