Commit b97e36cf authored by Sigrid Suski's avatar Sigrid Suski

Exception/Error message if no webp support available

parent acda718b
......@@ -62,7 +62,7 @@ final class Editor implements EditorInterface
$position = new Position( $position, $offsetX, $offsetY );
// Position is for $image2. $image1 is canvas.
list( $offsetX, $offsetY ) = $position->getXY( $image1->getWidth(), $image1->getHeight(), $image2->getWidth(), $image2->getHeight() );
[ $offsetX, $offsetY ] = $position->getXY( $image1->getWidth(), $image1->getHeight(), $image2->getWidth(), $image2->getHeight() );
// Check if it overlaps
if ( ( $offsetX >= $image1->getWidth() ) or
......@@ -134,7 +134,7 @@ final class Editor implements EditorInterface
$this->_blendScreen( $canvas, $gd1, $gd2, $loopStartY, $loopEndY, $loopStartX, $loopEndX, $offsetX, $offsetY, $opacity );
}
else {
throw new \Exception( sprintf( 'Invalid blend type "%s".', $type ) );
throw new \Exception( sprintf( 'Invalid blend type "%s"', $type ) );
}
}
}
......@@ -215,14 +215,14 @@ final class Editor implements EditorInterface
}
if ( 'smart' === $position ) { // Smart crop
list( $x, $y ) = $this->_smartCrop( $image, $cropWidth, $cropHeight );
[ $x, $y ] = $this->_smartCrop( $image, $cropWidth, $cropHeight );
}
else {
// Turn into an instance of Position
$position = new Position( $position, $offsetX, $offsetY );
// Crop position as x,y coordinates
list( $x, $y ) = $position->getXY( $image->getWidth(), $image->getHeight(), $cropWidth, $cropHeight );
[ $x, $y ] = $position->getXY( $image->getWidth(), $image->getHeight(), $cropWidth, $cropHeight );
}
......@@ -358,7 +358,7 @@ final class Editor implements EditorInterface
return $this;
}
list( $r, $g, $b, $alpha ) = $color->getRgba();
[ $r, $g, $b, $alpha ] = $color->getRgba();
$colorResource = imagecolorallocatealpha( $image->getCore(), $r, $g, $b,
$this->gdAlpha( $alpha )
......@@ -562,7 +562,7 @@ final class Editor implements EditorInterface
$this->resizeFit( $image, $newWidth, $newHeight );
break;
default:
throw new \Exception( sprintf( 'Invalid resize mode "%s".', $mode ) );
throw new \Exception( sprintf( 'Invalid resize mode "%s"', $mode ) );
}
return $this;
......@@ -711,7 +711,7 @@ final class Editor implements EditorInterface
}
$color = ( $color !== null ) ? $color : new Color( '#000000' );
list( $r, $g, $b, $alpha ) = $color->getRgba();
[ $r, $g, $b, $alpha ] = $color->getRgba();
$old = $image->getCore();
$new = imagerotate( $old, $angle, imagecolorallocatealpha( $old, $r, $g, $b, $alpha ) );
......@@ -789,7 +789,12 @@ final class Editor implements EditorInterface
break;
case ImageType::WEBP:
imagewebp( $image->getCore(), $file, $quality );
if ( function_exists( 'imagewebp' ) ) {
imagewebp( $image->getCore(), $file, $quality );
}
else {
throw new \Exception( sprintf( 'Cannot create %s; WEBP images are not supported', pathinfo( $file, PATHINFO_FILENAME ) ) );
}
break;
case ImageType::PNG :
......@@ -836,7 +841,7 @@ final class Editor implements EditorInterface
$color = ( $color !== null ) ? $color : new Color( '#000000' );
$font = ( $font !== '' ) ? $font : Grafika::fontsDir() . DIRECTORY_SEPARATOR . 'LiberationSans-Regular.ttf';
list( $r, $g, $b, $alpha ) = $color->getRgba();
[ $r, $g, $b, $alpha ] = $color->getRgba();
$colorResource = imagecolorallocatealpha(
$image->getCore(),
......@@ -1251,7 +1256,7 @@ final class Editor implements EditorInterface
asort( $hist );
end( $hist );
$pos = key( $hist ); // last key
list( $x, $y ) = explode( '-', $pos );
[ $x, $y ] = explode( '-', $pos );
$x = round( $x * ( $origW / $resizeW ) );
$y = round( $y * ( $origH / $resizeH ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment