Commit 47690ee1 authored by Radek Suski's avatar Radek Suski

support for webp images

parent 728c86bf
......@@ -371,6 +371,8 @@ class CURL
return [ 'err' => $err[ 'http_code' ], 'msg' => Framework::Txt( 'NO_CONNECT', 'https://' . $url ) ];
}
$res = stream_context_create( [ 'ssl' => [ 'capture_peer_cert' => true ] ] );
// @todo we can try to catch and if validation fails do it w/o but give the user a warning
// $res = stream_context_create( [ 'ssl' => [ 'capture_peer_cert' => true, 'verify_peer' => false, 'verify_peer_name' => false ] ] );
$client = stream_socket_client( "ssl://{$url}:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $res );
$cont = stream_context_get_options( $client );
if ( !$errno ) {
......
<?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
* @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.
*
* 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.
*/
......@@ -48,7 +45,7 @@ class Image extends File
}
/**
* @param int $sections
* @param int $sections
* @param bool $array
*
* @return array|bool
......@@ -90,8 +87,8 @@ class Image extends File
* @param $width
* @param $height
*
* @throws Exception
* @return $this
* @throws Exception
*/
public function & resample( $width, $height )
{
......@@ -117,21 +114,20 @@ class Image extends File
return $this;
}
public function saveAs( $path )
public function saveAs( $path, $type = null )
{
return $this->editor
->save( $this->image, $path, null, Framework::Cfg( 'image.jpeg_quality', 90 ) );
->save( $this->image, $path, $type, Framework::Cfg( 'image.quality', 90 ) );
}
public function save()
public function save( $type = null )
{
$this->createEditor();
return $this->editor
->save( $this->image, $this->_filename, null, Framework::Cfg( 'image.jpeg_quality', 90 ) );
->save( $this->image, $this->_filename, $type, Framework::Cfg( 'image.quality', 90 ) );
}
/**
* Rotate image
*
......
......@@ -788,6 +788,10 @@ final class Editor implements EditorInterface
break;
case ImageType::WEBP:
imagewebp( $image->getCore(), $file, $quality );
break;
case ImageType::PNG :
// PNG is lossless and does not need compression. Although GD allow values 0-9 (0 = no compression), we leave it alone.
imagepng( $image->getCore(), $file );
......@@ -1253,4 +1257,4 @@ final class Editor implements EditorInterface
return [ $x, $y ];
}
}
\ No newline at end of file
}
......@@ -18,4 +18,6 @@ class ImageType {
const PNG = 'PNG';
const WBMP = 'WBMP';
}
\ No newline at end of file
const WEBP = 'WEBP';
}
......@@ -630,6 +630,11 @@ final class Editor implements EditorInterface
$image->getCore()->writeImage($file);
break;
case ImageType::WEBP:
$image->getCore()->setImageFormat('webp' );
$image->getCore()->writeImage( $file );
break;
default: // Defaults to jpeg
$quality = ($quality === null) ? 75 : $quality; // Default to 75 (GDs default) if null.
$quality = ($quality > 100) ? 100 : $quality;
......@@ -824,4 +829,4 @@ final class Editor implements EditorInterface
}
}
}
\ No newline at end of file
}
......@@ -32,7 +32,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
### 1.0.13 (31 Juli 2020)
(+) Added support for WEBP images into Grafika
### 1.0.12 (30 May 2020)
......
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