Commit b14b9a05 authored by Radek Suski's avatar Radek Suski
parents cfeda124 fc061338
......@@ -44,5 +44,5 @@ abstract class C
const NO = 0;
const ROOT = JPATH_ROOT;
const DS = DIRECTORY_SEPARATOR;
const VERSION = '1.0.13';
const VERSION = '1.1';
}
......@@ -16,8 +16,8 @@ Url: https://www.Sigsiu.NET
Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
@license GNU/LGPL Version 3
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
See https://www.gnu.org/licenses/gpl.html and https://www.sigsiu.net/licenses.
as published by the Free Software Foundation, and under the additional terms according section 7 of LGPL v3.
See https://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
......@@ -31,6 +31,18 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
(!) Change
### 1.1 (31 July 2020)
(+) Added support for WEBP images into Grafika
(+) Introducing of semantic versioning
(+) webp_quality config key for WEBP images added
(!) Image->saveAs() creates editor object if it not already exists
(#) Braces of placeholders aree changed to entities when in urls (Issue #11)
(#) Usage of wrong translation method for some error messages (Txt() instead of Error())
### 1.0.13 (05 June 2020)
(+) Output of error messages added
......
......@@ -17,7 +17,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* @created Thu, Dec 1, 2016 by Radek Suski
* @modified 02 June 2020 by Sigrid Suski
* @modified 17 July 2020 by Sigrid Suski
*/
namespace Sobi\FileSystem;
......@@ -221,7 +221,7 @@ abstract class FileSystem
}
$return = \Jfile::write( $file, $buffer );
if ( $return === false ) {
throw new Exception( Framework::Txt( 'CANNOT_WRITE_TO_FILE_AT', $file ) );
throw new Exception( Framework::Error( 'CANNOT_WRITE_TO_FILE_AT', $file ) );
}
else {
return $return;
......@@ -272,7 +272,7 @@ abstract class FileSystem
{
$path = self::Clean( $path );
if ( !( \JFolder::create( $path, $mode ) ) ) {
throw new Exception( Framework::Txt( 'CANNOT_CREATE_DIR', str_replace( C::ROOT, null, $path ) ) );
throw new Exception( Framework::Error( 'CANNOT_CREATE_DIR', str_replace( C::ROOT, null, $path ) ) );
}
else {
return true;
......
<?php
/**
* @package : Sobi Framework
* @package: Sobi Framework
*
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: https://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2018 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
*
* @copyright Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
* See https://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* @modified 27 July 2020 by Sigrid Suski
*/
namespace Sobi\FileSystem;
......@@ -20,6 +25,10 @@ use Grafika\Grafika;
use Sobi\Framework;
use Sobi\Error\Exception;
/**
* Class Image
* @package Sobi\FileSystem
*/
class Image extends File
{
/*** @var array */
......@@ -34,6 +43,8 @@ class Image extends File
/**
* @param $transparency
*
* @throws \Exception
*/
public function setTransparency( $transparency )
{
......@@ -45,7 +56,7 @@ class Image extends File
}
/**
* @param int $sections
* @param int $sections
* @param bool $array
*
* @return array|bool
......@@ -66,12 +77,16 @@ class Image extends File
/**
* Resample image
* Resample image.
*
* @param $width
* @param $height
* @param string $position
* @param int $offsetX
* @param int $offsetY
*
* @return $this
* @throws \Exception
*/
public function & crop( $width, $height, $position = 'center', $offsetX = 0, $offsetY = 0 )
{
......@@ -82,7 +97,7 @@ class Image extends File
}
/**
* Resample image
* Resample image.
*
* @param $width
* @param $height
......@@ -92,7 +107,7 @@ class Image extends File
*/
public function & resample( $width, $height )
{
list( $wOrg, $hOrg, $imgType ) = getimagesize( $this->_filename );
[ $wOrg, $hOrg, $imgType ] = getimagesize( $this->_filename );
/* if not always and image is smaller */
......@@ -114,36 +129,58 @@ class Image extends File
return $this;
}
/**
* @param string $path
* @param null $type
*
* @return bool|\Grafika\EditorInterface
* @throws Exception
*/
public function saveAs( $path, $type = null )
{
if ( !$this->image ) {
$this->createEditor();
}
$quality = ( $type == 'WEBP' ) ? Framework::Cfg( 'image.webp_quality', 80 ) : Framework::Cfg( 'image.jpeg_quality', 90 );
return $this->editor
->save( $this->image, $path, $type, Framework::Cfg( 'image.quality', 90 ) );
->save( $this->image, $path, $type, $quality );
}
/**
* @param null $type
*
* @return bool|\Grafika\EditorInterface
* @throws Exception
*/
public function save( $type = null )
{
$this->createEditor();
$quality = ( $type == 'webp' ) ? Framework::Cfg( 'image.webp_quality', 80 ) : Framework::Cfg( 'image.jpeg_quality', 90 );
return $this->editor
->save( $this->image, $this->_filename, $type, Framework::Cfg( 'image.quality', 90 ) );
->save( $this->image, $this->_filename, $type, $quality );
}
/**
* Rotate image
* Rotate image.
*
* @param $angle
*
* @return $this
* @throws \Exception
*/
public function & rotate( $angle )
{
$this->createEditor();
$this->editor->rotate( $this->image, $angle );
return $this;
}
/**
* @return bool
* @throws \Exception
*/
public function fixRotation()
{
......@@ -169,6 +206,7 @@ class Image extends File
}
/**
* @throws \Exception
*/
protected function createEditor()
{
......
<?php
/**
* @package: Sobi Framework
*
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: https://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2016 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
*
* @copyright Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
*
* See https://www.gnu.org/licenses/lgpl.html and https://www.sigsiu.net/licenses.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* @created Thu, Dec 1, 2016 by Radek Suski
* @modified 27 May 2020 by Sigrid Suski
* @modified 15 July 2020 by Sigrid Suski
*/
namespace Sobi\Input;
defined( 'SOBI' ) || exit( 'Restricted access' );
use AthosHun\HTMLFilter\Configuration;
use AthosHun\HTMLFilter\HTMLFilter;
use Sobi\Error\Exception;
......@@ -27,8 +31,6 @@ use Sobi\FileSystem\FileSystem;
use Sobi\Framework;
use Sobi\Utils\Serialiser;
defined( 'SOBI' ) || exit( 'Restricted access' );
/**
* @method integer Sid() public static Sid( $request = 'request', $default = 0 )
* @method integer Cid() public static Cid( $request = 'request', $default = 0 )
......@@ -220,7 +222,11 @@ abstract class Input
}
$html = Request::Instance()->{$request}->getRaw( $name, $default );
return str_replace( '&#13;', "\n", $filter->filter( $config, $html ) );
$html = str_replace( '&#13;', "\n", $filter->filter( $config, $html ) );
$html = str_replace( 'href="%7B', "href=\"{", $html );
$html = str_replace( '%7D"', "}\"", $html );
return $html;
}
/**
......
......@@ -2,11 +2,4 @@
Since version 1.3.3, SobiPro uses the Sobi Framework for common functions. This is the first step needed to provide our community with additional components in the future.
However, there is a necessary requirement to use the framework. This is no new requirement, as it is already compulsory for the SobiPro template settings available since SobiPro 1.3.0.
In order to use the Sobi Framework out of the box, the Phar extension has to be available.
Phar is not only needed for the Sobi Framework, but also for the Template Settings and the LESS compiler of SobiPro.
If you have Suhosin installed, make sure that Phar support is enabled in Suhosin. This is a common problem on some servers.
Read more in https://www.sigsiu.net/center/sobipro-component/154-sobi-framework
\ No newline at end of file
......@@ -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 ) );
......@@ -747,7 +747,7 @@ final class Editor implements EditorInterface
* @param Image $image
* @param string $file File path where to save the image.
* @param null|string $type Type of image. Can be null, "GIF", "PNG", or "JPEG".
* @param null|string $quality Quality of image. Applies to JPEG only. Accepts number 0 - 100 where 0 is lowest and 100 is the highest quality. Or null for
* @param null|string $quality Quality of image. Applies to JPEG and WEBP only. Accepts number 0 - 100 where 0 is lowest and 100 is the highest quality. Or null for
* default.
* @param bool|false $interlace Set to true for progressive JPEG. Applies to JPEG only.
* @param int $permission Default permission when creating non-existing target directory.
......@@ -789,7 +789,15 @@ final class Editor implements EditorInterface
break;
case ImageType::WEBP:
imagewebp( $image->getCore(), $file, $quality );
if ( function_exists( 'imagewebp' ) ) {
$quality = ( $quality === null ) ? 75 : $quality; // Default to 75 (GDs default) if null.
$quality = ( $quality > 100 ) ? 100 : $quality;
$quality = ( $quality < 0 ) ? 0 : $quality;
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 +844,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 +1259,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