? No Code Attached Yet
avatar schnuti
schnuti
7 Oct 2019

Is your feature request related to a problem? Please describe.

Did you know that you can set max-width and max height for image uploads (and edited/resized images) in the action/resize plug-in?
If you set one or both of those parameters, your concern is probably not primarily the size in pixel but the resulting bytes.
As no quality parameters are set, the resulting file size in bytes most often is much larger than the original upload. Of course depending on the size and the compression of the original.

Describe the solution you'd like

Set quality parameters for jpeg and png files when resizing with PHP.

Additional context

I have edited and tested code and can make a PR, if you agree to the issue.

avatar schnuti schnuti - open - 7 Oct 2019
avatar joomla-cms-bot joomla-cms-bot - change - 7 Oct 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Oct 2019
avatar alikon
alikon - comment - 9 Oct 2019

can be a good feature

avatar Milglius
Milglius - comment - 15 Oct 2019

this would be the best feature imho :)

@schnuti please make a PR this is big joomla issue and should be fixed asap :)

now we have big problem with 9 MB image uploads :(

I am very glad that you try to fix this :)

avatar schnuti
schnuti - comment - 15 Oct 2019

@Milglius Did you test to activate the "batch"-tab parameters with max width and height? Would be interesting to know the original and resized sizes in bytes using your large images as is.

I'll add a PR with compression (=quality) parameters ASAP.

avatar Milglius
Milglius - comment - 16 Oct 2019

No, if you need I try to test this, but I do not know how to activate the "batch"-tab parameters with max width and height?

Thanks @schnuti I'll try to test PR with compression (=quality) parameters ASAP.

avatar Milglius
Milglius - comment - 2 Nov 2019

@schnuti I can't find your PR, have you submitted it ?

avatar Milglius
Milglius - comment - 11 Dec 2019

Can someone point me where is the PR with compression (=quality) parameters schnuti wanted to submit? Or is it abandoned or is schnuti still working on it?

avatar korenevskiy
korenevskiy - comment - 25 Apr 2020

Please add the file renaming code to the image editing plugin.
I used to write myself a plugin J3 for renaming uploaded photos.
So that test editors and creators of unique content don't have problems with photo names when they suddenly have the same file name.
To prefix the file name with the date and material ID.
So that everything happens automatically.

use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
class plgSystemImageRename extends JPlugin {
    public function __construct(&$subject, $config=array()) 

        $image_rename = $this->params->get("image_auto_rename",FALSE);            
        if(empty($image_rename))            return; 

        $this->input = JFactory::getApplication()->input; 
	$files2        = $this->input->files->get('Filedata', array(), 'array');     

        if(empty($files2) && empty($_FILES['Filedata']))            return;
           
        if(is_array($_FILES['Filedata']['name'])){// && isset($file['name'])
            foreach ($_FILES['Filedata']['name'] as $i => &$file)
                $_FILES['Filedata']['name'][$i] = $this->getNewName($_FILES['Filedata']['name'][$i]);
        }
        elseif(is_string($_FILES['Filedata']['name'])){
            $_FILES['Filedata']['name'] = $this->getNewName($_FILES['Filedata']['name']);
        }
            
        if(empty($files2))                return;
            
        if(isset($files2['name'])){
             $files2['name'] = $this->getNewName($files2['name']);
        }
        elseif (isset($files2[0]['name'])) {
            foreach ($files2 as $i => &$file)
                $file['name'] = $this->getNewName($file['name']);
        }
    }
    public function getNewName($str = ''){ 
        $image_date_rename = $this->params->get("image_date_rename",FALSE);
        $image_format_rename = $this->params->get("image_format_rename","Ymd_");
            if($image_date_rename == 2 && $image_format_rename)
                $str = date($image_format_rename).$str;
            elseif($image_date_rename)
                $str = date("Ymd_").$str;
            $str = str_replace(' ', '_', $str);
            $str = str_replace('-', '_', $str);
            $str = JFactory::getLanguage()->transliterate($str);  
            return $str;
    }
}
avatar ReLater
ReLater - comment - 27 Apr 2020

@korenevskiy

Please don't mix different issues. You have posted your request already at #28792 (comment) . This issue here is about quality settings for resized images.

Thank you

avatar Hackwar Hackwar - change - 19 Feb 2023
Labels Added: ? No Code Attached Yet
Removed: ?
avatar Hackwar Hackwar - labeled - 19 Feb 2023

Add a Comment

Login with GitHub to post a comment