Giter Club home page Giter Club logo

imageoptimizer's Introduction

TYPO3 ImageOptimizer Extension

Lossless image optimization. Process jpg/png/gif/svg images with binaries and parameters of your choice.

Note: JPG and PNG were yesterday. If you want to serve images in new formats like avif and webp including auto detection and asynchronous generation, then imgproxy may fit your needs. #webvitals

Features

  • Optimize images on upload or after processing (files in fileadmin/_processed_/)
  • Binaries, paths and their parameters are configurable

Installation

Debian/Ubuntu: apt-get install optipng jpegoptim libjpeg-turbo-progs gifsicle

svgo is installable via NPM npm install -g svgo

Configuration options

Extension Manager configuration options

Debugging

  • Commands are tested in the Extension Settings module
  • Logging API: See file/database log

imageoptimizer's People

Contributors

bjo3rnf avatar christophlehmann avatar danielruf avatar dennismetz avatar dependabot[bot] avatar garvinhicking avatar kaystrobach avatar koehnlein avatar maximilian-walter avatar mueller-sebastian avatar neoblack avatar revoltek-daniel avatar sascha-egerer avatar simonschaufi avatar snk-typo3-team avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

imageoptimizer's Issues

[BUG] Log shows duplicated path - Binary not found

Hi Christoph,

I configured the path to the jpgBinary and according to the report Binary /files/bin/jpegoptim can be found. However, simliar to #11 , in the logs the path appears twice.

/files/bin//files/bin/optipng -o2 /home/www/******/html/typo3/fileadmin/_processed_/4/d/csm_Lebensmittel_565a6f6af7.png 2>&1 exited with 127. Output was: sh: /files/bin//files/bin/optipng: No such file or directory (msg#4.0.127)

Any ideas?

Trim Error keeps flodding Log file

Hello Christoph,

thanks for this cool plugin! I've just stumpled upon a nasty thing:
After activating the plugin the error log file (logs only errors!) is being flodded (several hundred lines per minute) with this message over and over:
PHP Warning: trim() expects parameter 1 to be string, object given in /html/typo3/typo3_src-7.6.23/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php on line 6412

Line 6412 says: "$linkParameter = trim(isset($conf['parameter.']) ? $this->stdWrap($conf['parameter'], $conf['parameter.']) : $conf['parameter']);"
Any idea how to get rid of that? I've turned off repeated errors and sources in PHP but it doesn't helped.

PHP 8.1: Missing array key exists check in OptimizeImageService throws exception

We added webp to our list of image file extensions to generate webp versions directly in fluid templates.
The OptimizeImageService does not check if the config exists and thus throws an exception when it renders the template

PHP Warning: Undefined array key "webpOnProcessing" in /var/www/html/src/private/typo3conf/ext/imageoptimizer/Classes/OptimizeImageService.php line 70

if ((bool)$this->configuration[$extension . 'On' . $when] === false && $testMode === false) {

This should prevent the exception if no configuration is set

if (!isset($this->configuration[$extension . 'On' . $when]) || ((bool)$this->configuration[$extension . 'On' . $when] === false && $testMode === false)) {

Make extension installable via composer

For composer based TYPO3 installations it would be great to have a composer.json in the package and have it on packagist.

As we plan to try this package, we could add create the file and provide a merge request.

Install Tool Extension Configuration throws Error at TYPO3 12

Current Case:

  • TYPO3 12.4.10
  • Install Tool / Extension Configuration throws error "Too few arguments"

image

Solution in File /Classes/ConfigurationTest.php

change

public function __construct()
{   
        $this->service = GeneralUtility::makeInstance(OptimizeImageService::class);
        $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
        $this->flashMessageRenderer = GeneralUtility::makeInstance(BootstrapRenderer::class);
}

to

public function __construct()
{   
        $this->service = GeneralUtility::makeInstance(OptimizeImageService::class, GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class));
        $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
        $this->flashMessageRenderer = GeneralUtility::makeInstance(BootstrapRenderer::class);
 }

Cheers :)

[BUG] Extension removes = from command

Hi,

we use the extension version 1.0.0 with TYPO3 6.2 and FreeBSD. I've configured the optimization for JPG files with jpegoptim and the following parameters in the extension settings:
--strip-all --max=80 --all-progressive %s

But the = is stripped from the command:
screenshot from 2017-03-09 08-50-03

This works:
--strip-all -m80 --all-progressive %s

Regards
Daniela

I am getting error /usr/bin/jpegoptim: not found

JPG: /usr/bin/jpegoptim --strip-all '/var/www/html/XXXX/XXXXXX/typo3temp/var/transient/imageoptimizer4052186309425189030jpg' 2>&1
sh: 1: /usr/bin/jpegoptim: not found

JPG on Upload: /usr/bin/jpegoptim --strip-all '/var/www/html/XXXX/XXXXX/typo3temp/var/transient/imageoptimizer5556720757223879253jpg' 2>&1
sh: 1: /usr/bin/jpegoptim: not found.

error

TYPO3 v12 compatibility

Hello,

Could you tell me if you have plan any update of this nice extension to TYPO3 v12?

Any date for that?

Best,

Integrating jpegoptim as an alternative?

Hi!

very nice tool! I have started playing around with this and mentioned that google pagespeed still complains about my (jpeg) filesize. After some investigation it turned out that reducing the image quality would do the trick (see http://webmasters.stackexchange.com/questions/102094/google-pagespeed-new-image-compression-rules there is a 2017-01 update).
Would it be an option to integrate jpegoptim as an alternative with a parameter for the -m switch?
Secound point is an option to use the quality switch only on images processed by Typo3 and not on images which are referenced directly.

Regards,
Sebastian

Exception when WebP Images are created in Fluid

From time to time this exception pops up in the frontend, when i generate WebP images (out of JPGs) via <f:image fileExtension="webp"> of <f:uri.image fileExtension="webp">.

(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception
PHP Warning: Undefined array key "webpOnProcessing" in /Users/***/typo3conf/ext/imageoptimizer/Classes/OptimizeImageService.php line 70

TYPO3 11.5.13
imageoptimizer 3.1.0

can you explain?

hey there...
i installed your ext and have a question.
i enabled logging and in log is this:

/kunden/homepages/28/d574274134/htdocs//kunden/homepages/28/d574274134/htdocs/jpegoptim --strip-all /kunden/homepages/28/d574274134/htdocs/update7/fileadmin/processed/e/4/preview_Dialog-Wehling9-web_911423aa83.jpg 2>&1 exited with 127. Output was: sh: 1: /kunden/homepages/28/d574274134/htdocs//kunden/homepages/28/d574274134/htdocs/jpegoptim: not found (msg#4.0.127)

look at the last words "not found".
but the reports say the binary is found and in use. Why is this?

[TASK] implement mozjpeg

mozjpeg is bases on libjpeg-turbo, combines several appeoaches and provides smaller progressive images.

Progressive images generally improve the perceived performance and produce better speedindex values.

Error Message not showing missing Binary Name

When using imageoptimizer on a system that is missing binaries e.g. jpegoptim, optipng or gifsicle, its just stating that "Binary" was not found. This led to confusion on my part.

Core: Exception handler (WEB): 
Uncaught TYPO3 Exception: #1488631746: Binary not found
RuntimeException thrown in file
.../imageoptimizer/Classes/OptimizeImageService.php in line 42. 
Requested URL: https://example.com/.../

I guess that the missing Binary should be printed inbetween Binary {HERE} not found.

But this is not the case on my system. Am I missing something?

PHP 8 compatibility

Hi, I am testing PHP 8.1 and I noticed that there is a small error in the status report.

PHP Warning: Undefined array key "svgOnProcessing" in .../typo3conf/ext/imageoptimizer/Classes/StatusReport.php line 26

Debug Log (writelog()) tries to sets detail_nr to 1467124014)

$GLOBALS['BE_USER']->writelog(4, 0, 0, 1467124014, $command . ' exited with ' . $returnValue . '. Output was: ' . implode(' ', $output), $output);

This tries to set detail_nr in sys_log to 1467124014 but field detail_nr in sys_log table is "tinyint(3)". So field value is always 127 which is confusing (e.g. in BE log where message displays (msg#4.0.127) )

extension not working on typo3 8.6

hi,

i installed extension on new typo3 8.6.1 but the extension class are not loaded. so i found 2 bugs:

file ext_conf_templates.txt basic configuration is missing - if optimizeOnUpload = 1 and optimizeAfterProcessing = 1 are not set, $signalSlotDispatcher->connect.... in ext_localconf.php is not running:

cat=basic/Enable Features/300; type=boolean; label=Optimize files on upload: This is useful when you reference original files from fileadmin which don't need to be processed

optimizeOnUpload = 1

cat=basic/Enable Features/400; type=boolean; label=Optimize files after processing: Optimize files which are processed (cropped, scaled, ...).

optimizeAfterProcessing = 1

file ext_localconf.php following seems missing, because an error "connect on null" is shown without:
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);

martin

New release for TYPO3 9.5 LTS

Hi Christoph,

I can see there already is a branch for this task. Is there anything left to do which you would like to see a PR for?

Thanks in advance.

Cheers
Björn

[FEATURE] Implement interface for external services

For example https://tinypng.com/

  • Add OptimizeImageInterface with process() function
  • Use interface in OptimizeImageService
  • Add service registration
  • Register OptimizeImageService in service registration like

$GLOBALS['TYPO3_CONF_VARS']['EXT']['ImageOptimizer']['Services'][] = 'Lemming\Imageoptimizer\ OptimizeImageService';

[FEATURE] add local binaries

Hey, thanks for the great plugin.

It would be very cool to have some precompiled binaries shipped with the plugin, like EWWW Image optimizer for WordPress does.
So the plugin would work on more systems/out of the box.

Greetings Arne

sharp / libvips

https://github.com/lovell/sharp uses libvips which is ideal for web, provides progressive options, consumes not much memory, ...

One of both might be interesting to have a fast lowmemory image processing solution for web.

[FEATURE] Integrate TinyPNG API

Hi Christoph,

I just made some tests with the Tinify Service over at tinypng.com.
The results are very impressing. Have you had a look at this service before?

I was just wondering, if it was somehow possible to integrate such a service in the TYPO3 image upload workflow. Then I discovered your extension, which provides just the mechanics, which would be needed to achieve this.

In the part where your code is doing the server side optimisations, the tinify function could be integrated alternatively, maybe:
https://tinypng.com/developers/reference/php

Greetings,
Uwe

Neuen Tag / Version für Packagist

Hallo,
danke für die coole Extension und das du auch schon den Fix in der composer.json gemacht hast (extension-key).
Könntest du hierfür eine neue Version machen bzw. einen Tag erstellen, damit auf Packagist die neue Änderung vorhanden ist? :-)
Vielen Dank

Call to a member function process() on null

Everytime i'm trying to change an image i'm getting the following error:

Call to a member function process() on null
xxxxx\typo3conf\ext\imageoptimizer\Classes\EventListener\AfterFileProcessing.php line 11

When i'm trying to upload an image i'm getting the following error:

Call to a member function process() on null
Error thrown in file xxxxx\typo3conf\ext\imageoptimizer\Classes\EventListener\BeforeFileAdded.php in line 10

TYPO3 v10.4.2
ImageOptimizer 3.0.0
Windows 10 / Linux (Local and Dev)

The same setup is working fine with TYPO3 9.5.x and ImageOptimizer 2.x
BTW: thanks for your effort, you´re doing a great job!

Mention open_basedir restriction in documentation

Suggestion for the documentation: TYPO3\CMS\Core\Utility\CommandUtility::getCommand uses 'is_executable()' to check if the binaries are present and executable. When a open_basedir restriction is in place, that check fails, although calling the binaries with exec() works fine (at least, in our enviroment).

V11 compatible version?

Hi Christoph,
is it possible to prepare a v11 compatible version? dev-master would be fine for testing purposes.
I am trying to update an installation to v11 and I would like to prevent a fork of your extension for a single line of code.

thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.