scaleDimensions example

$this->logger->error('Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
      return FALSE;
    }
    return TRUE;
  }

  /** * {@inheritdoc} */
  public function transformDimensions(array &$dimensions$uri) {
    if ($dimensions['width'] && $dimensions['height']) {
      Image::scaleDimensions($dimensions$this->configuration['width']$this->configuration['height']$this->configuration['upscale']);
    }
  }

  /** * {@inheritdoc} */
  public function getSummary() {
    $summary = [
      '#theme' => 'image_scale_summary',
      '#data' => $this->configuration,
    ];
    

class ImageTest extends TestCase {

  /** * Tests all control flow branches in image_dimensions_scale(). * * @dataProvider providerTestScaleDimensions */
  public function testScaleDimensions($input$output) {
    // Process the test dataset.     $return_value = Image::scaleDimensions($input['dimensions']$input['width']$input['height']$input['upscale']);

    // Check the width.     $this->assertEquals($output['dimensions']['width']$input['dimensions']['width']sprintf('Computed width (%s) does not equal expected width (%s)', $output['dimensions']['width']$input['dimensions']['width']));

    // Check the height.     $this->assertEquals($output['dimensions']['height']$input['dimensions']['height']sprintf('Computed height (%s) does not equal expected height (%s)', $output['dimensions']['height']$input['dimensions']['height']));

    // Check the return value.     $this->assertEquals($output['return_value']$return_value, 'Incorrect return value.');
  }

  
Home | Imprint | This part of the site doesn't use cookies.