GithubHelp home page GithubHelp logo

xperseguers / t3ext-image_autoresize Goto Github PK

View Code? Open in Web Editor NEW
16.0 6.0 21.0 3.71 MB

TYPO3 Extension image_autoresize. Simplify the way your editors may upload their images.

Home Page: https://extensions.typo3.org/extension/image_autoresize

License: GNU General Public License v3.0

PHP 98.74% CSS 1.10% HTML 0.16%

t3ext-image_autoresize's Introduction

Resize images automatically

Latest Stable Version GitHub license Crowdin Total Downloads

This extension automatically resizes images to a given maximum height/width right after they have been uploaded to the TYPO3 website. The aspect ratio is of course kept.

The idea behind this extension is that TYPO3 should make both administrators and editors happy. Administrators want the website’s footprint on server as small as possible to be able to handle backups efficiently and want the web server to deliver the pages as quick as possible. On the other hand, editors should be able to do their job and not bother with technical considerations such as the size of a picture on disk or that uploading their wonderful sunset taken during holidays with their 12 MP camera will slow down the time rendering of their great photo gallery where pictures are being shown with a maximum definition of 800 × 600 pixels. Moreover, editors are either not aware of this or are simply unable to “prepare” their pictures as they are using a foreign computer (in a cyber café) or on the road with their laptop, neither of them running their beloved image editing software.

General configuration settings let you choose which directories should be somehow “monitored” for uploaded pictures and define the file types that should be handled (e.g., “jpg” and “tif” but not “png” nor “gif”) and a file size threshold (e.g., “skip any picture smaller than 400 KB”). After all, if an editor managed to create a picture of many mega-pixels that weights only a few KB, why should we bother?

Screencast

The team from jweiland.net prepared a screencast showing how to install and configure this extension in your TYPO3 website: https://jweiland.net/video-anleitungen/typo3/interessante-typo3-extensions/image-autoresize.html.

Screenshot

The following two figures show how an administrator may easily configure rules to resize uploaded images:

General Configuration

General Options

Full Documentation

Please head to https://docs.typo3.org/p/causal/image_autoresize/main/en-us/ for the complete extension manual.

Contribution

Please refer to https://docs.typo3.org/p/causal/image_autoresize/main/en-us/Links.html for instructions.

t3ext-image_autoresize's People

Contributors

echavaillaz avatar froemken avatar josefglatz avatar jrenggli avatar limeuwe avatar majpay avatar mediaessenz avatar movedaniel avatar mz-aimcom avatar nigelmann avatar no5251 avatar sgrossberndt avatar t3webman avatar webian avatar wtfred avatar xperseguers avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

t3ext-image_autoresize's Issues

Resizing by Task does not update FAL records

Hello,

I have 9 huge images in my directory. Calling your task needs a while and after that, all images are smaller. Perfect. But Filesize, M-Time and Dimensions are not updated in sys_file_metadata.

Nice greetings

Stefan

Empty configuration in TYPO3 v9

Configuration was previously written to $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['image_autoresize_ff']. Problem is that in TYPO3 v9, whenever you go to Admin Tools > Settings and try to configure (other) extensions, this automatically cleans up what seems to be useless extension configuration and thus destroys the previously saved configuration for this extension.

Does not work

Installed und configured correctly bug after image upload, nothings happens.
Typo3 8.7.9
Php 7.0

[Suggestion] Default configuration by typoscript

Hello,

This is not an issue, but a suggestion: it would be nice if we could define a default configuration with typoscript. This way, we could use our own extension to preset things like max_width & max_height.

If you think it's relevant, i could try to make it and PR, i think it would only require to rewrite a bit ConfigurationController->getDefaultConfiguration(), and add constants.typoscript & setup.typoscript
Thanks for reading :)

compatibility 9.4

Is there an update for TYPO3 v9.4 in the pipe?
Would be cool as I've just a project with that need.

Undefined variable $_EXTKEY throws exception

When using the extension with TYPO3 v11 this exception comes up:

PHP Warning: Undefined variable $_EXTKEY in /app/public/typo3conf/ext/image_autoresize/ext_localconf.php line 27

TYPO3 documentation states:

Changed in version 10.0: These variables are no longer declared in ext_tables.php and ext_localconf.php files: $_EXTKEY, $_EXTCONF, T3_SERVICES, T3_VAR, TYPO3_CONF_VARS, TBE_MODULES, TBE_MODULES_EXT, TCA, PAGES_TYPES, TBE_STYLES

It seems that $_EXTKEY should not be used within ext_localconf.php anymore, because TYPO3 does not set it anymore. This sounds like it is the reason for the exception.

Do I miss something here or why would this exception be thrown? Thanks a lot!

The fileuploadhook is not called

Typo3: 8.7.8
image_autoresize: 1.8.1
Uploading images under File->filelist: there is no resizing.
Uploading images in a content element: there is no resizing.

I did some debugging:
The configuration in the extension seems correct to me.
The uploadfilehook (method: processUpload_postProcessAction) is never called.
The hook method has to be called from class Typo3\Core\DataHandling\DataHandler.
I put some debug-statements before the calling of the hookmethod: but it seems Typo3 never enters this code.
After all: I can't get the extension working.

Adding file without backend connection

Hi,

In our extension, connected fe_users can update their image. When a file is uploaded, it's added like this :
$file = $storage->addFile($fileTmpMedia, $folder, $fileMedia);
This raises an error from class CoreResourceStorageEventListener.php in processFile and sanitizeFileName functions because getBackendUser() cannot return null :

image

Thanks!

Troubles if core feature "simplifiedControllerActionDispatching" is activated

On TYPO3 9.5+, if you activate the core feature simplifiedControllerActionDispatching in "Settings > Feature Toggles", you can't access to the extension configuration anymore, see error message:

(1/1) ArgumentCountError

Too few arguments to function Causal\ImageAutoresize\Controller\ConfigurationController::mainAction(), 1 passed and exactly 2 expected

I guess it's because when you activate this feature, then then 2nd argument ResponseInterface is not passed.

Rule sets doesn't work properly

Hi,
I have image_autoresize v2.0.3 on TYPO3 8.7.
I set 4 directories to "General" tab option with 1:/.

When I set up rules on "Rule sets" tab, i write a rule on a subdirectory of a directory specified on the "General tab" with differents "File size treshold" and "Image dimensions" it seems to doesn't work. (treshold : 10M ; max width : 10000 ; max height : 10000)

Cause I go to the subdirectory to import a file (1950*1300 2Mo), but this file is resized every time following the rule defined on "General" tab.

My "General" tab option directory looks like it :
1:/fileadmin_x/fichiers/

My rule on "Rule sets" tab option for subdirectory looks like it :
1:/fileadmin_x/fichiers/subdir/subdir2/subdir3/

Any idea ?
Thank you in advance

Resize not working anymore for editors, if folder is set to 1:/user_upload/,uploads/

Resize is not working anymore for editors without admin rights, if the folder is set to "1:/user_upload/,uploads/".
Only "1:/,uploads/" is working.

TYPO3 10.4.23
image_autoresize 2.1.1
extractor 2.1.0
PHP 7.4
Composer based Installation

I discovered this by hazard. Some month or perhaps already one year ago with TYPO3 9.5 is still worked, I think.
Rulesets are not working too, but they also didn't work before.

grafik

PHP 7.4 compatibility

Hi,
Core: Error handler (BE): PHP Runtime Deprecation Notice: Array and string offset access syntax with curly braces is deprecated in .../ext/image_autoresize/Classes/Task/BatchResizeTask.php line 151
Braces {} have to replaced by brackets []

Error with PHP 8

Hey there, i read that the ext for PHP 8 works, but it don´t do it.
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1476107295: PHP Warning: Undefined array key "keep_metadata"
image_autoresize/Classes/Service/ImageResizer.php line 303

The upload don´t work, the files are not stored in Folder.

New release?

Hello Xavier,

there are some cool new Patches in master waiting for a new release. Do you have time to release a new version?

Stefan

Add support for FAL-based directory references

Hello,

I have entered a valid directory in your task, but it returns me an error:

"Cannot process non-existing directory: 1:/resize_images"

Seems you're working with getFileAbsFileName instead of ResourceFactory::retrieveFileOrFolderObject

Nice greetings

Stefan

Resizing not working in 9.5.30?

I installed the plugin (v2.1.1) in Typo3 9.5.30 and set configuration this way:
Bildschirmfoto 2021-08-30 um 15 52 36

When I upload an image to "/fileadmin/" nothing happens with that uploaded image (3.2 MB)
Bildschirmfoto 2021-08-30 um 15 53 27

Any idea what's going wrong here?

4th Argument of indexFile must be of type int, float given

Hello,

while uploading a file in FE context I get the error message:

Argument 4 passed to Causal\ImageAutoresize\Utility\FAL::indexFile() must be of type int, float given, called in ...CoreResourceStorageEventListener.php on line 192

Can you please cast the values of static::$metadata['COMPUTED']['Width'] and static::$metadata['COMPUTED']['Height'] in FileUpload.php to int?

Nice greetings

Stefan

Image resized even if smaller than the limit

Hi @xperseguers !
I noticed that uploading a JPG image 1600x1200, it was auto-resized to the same size 1600x1200 even if smaller than the size limit that is 1920x1920.

Debugging the code I found that image_autoresize create a temp file from the original image in any case and then checks if the temp image is still bigger and if it is then it discard it.

In this case, since the original image has the smallest JPG compression, the recreated tmp image is smaller than those hardcoded 10KB and so the original image is replaced by the tmp one. But this is not the wanted behavior at least in this use case.

I'm not sure about the solution for this use case. Maybe make the 10KB configurable?

Resizing does not work on certain settings

<?php
return [
    'directories' => '1:/',
    'file_types' => 'jpg,jpeg,png',
    'threshold' => '5120K',
    'max_width' => '5120',
    'max_height' => '3840',
    'max_size' => '100M',
    'auto_orient' => '1',
    'conversion_mapping' => 'ai => jpg,bmp => jpg,pcx => jpg,tga => jpg,tif => jpg,tiff => jpg',
    'keep_metadata' => '1',
    'resize_png_with_alpha' => '1',
];

Image is resized to 11107x7536. Why? I would expect it to be resized to a dimension where either width is 5120 or height is 3840 but not some random size.

Replacing a file does not clear a cache

Hello,

I have uploaded a big image (5000px) and the image was automatically resized (1024px). Perfect.
If I replace the image with another big uploaded image and click on the i-icon a PopUp appears. Pressing "show" shows my over 8MB big picture, but with a dimension of the previous image with width of 1024px. If I deactivate your extension the image will be shown fullsize (over 5000px).

Nice greetings

Stefan

Feature request: force conversion

It happens that a PNG is uploaded but not converted because transparency is detected even if visually there's no transparency. In this cases a button to force the conversion to JPG of a single image would be useful.

Leftover record in sys_file table

Using a code like this:

$image = $storage->addFile(
    '/domain.ext/htdocs/typo3temp/var/transient/tmp_file.bmp',
    $targetFolder,
    'target_name.bmp',
    DuplicationBehavior::REPLACE,
    true
);

the BMP file is correctly converted to a JPG with filename target_name.jpg with its own record in sys_file but a record for the transient tmp_file.bmp is left in sys_file table.

Wildcard in general configuration does not work

I have images in a protected storage in
/path/to/typo3/www/protected/aaa/bbb/ccc/images/
and
/path/to/typo3/www/protected/xxx/yyy/zzz/images/
so I added as directories definition protected/**/images/ in the general configuration. I did not add any rulesets.

When running the BatchResizeTask (without configuring directories there) it fails with

Given directory "/path/to/typo3/www/protected/**/images/" does not exist

In

https://github.com/xperseguers/t3ext-image_autoresize/blob/master/Classes/Task/BatchResizeTask.php#L102

the method batchResizePictures() is called with parameter protected/**/images/ which is expanded to
/path/to/typo3/www/protected/**/images/ in GeneralUtility::getFileAbsFileName() but the is_dir()-check in

https://github.com/xperseguers/t3ext-image_autoresize/blob/master/Classes/Task/BatchResizeTask.php#L104

fails as is_dir cannot cope with ** in the path.

Auto-Rotate broken in Typo3 11 and ImageMagick

Hello,
we are updating a website with Typo3 V8 to version 11.5.5 and noticed that the image orientation no longer fits. Images uploaded upside down are rotated correctly in V8. In V11 it doesn´t work anymore.

Regards

Replacing a file does not resize image

Hello,

I have uploaded a big image in filelist and yes, the image was automatically resized. Perfect. But, when I use TYPO3s replace feature while keeping the original filename your extension leaves the image untouched.
Would be perfect if your extension can also resize replaced images as well.

Nice greetings

Stefan

Error in scheduler because of flash message in TYPO3 9 LTS

Hello,
in this use case with TYPO3 9 LTS I have a scheduler that creates images so image_autoresize tries to resize them and display the flash messages. But then this error happens:
Argument 1 passed to TYPO3\\CMS\\Core\\Session\\Backend\\DatabaseSessionBackend::update() must be of the type string, null given, called in /typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php on line 1311

I'm not sure but maybe we should check if we are in CLI in this place:

if (TYPO3_MODE !== 'BE') {

changing the condition this way (TYPO3_MODE !== 'BE' || php_sapi_name() == 'cli') so it will not try to flash messages if run by scheduler.

Any news about PHP 8 compatibility?

Dear Xavier,
do you have any plans to lift imageautoresize to PHP versions 8.0 / 8.1?
Would be great - using you extension in projects where it is the last not working with php > 7.
Thank you very much for your information,
Thomas

Warnings after install

I get three PHP Warnings after install, when running the configuration in EM:

Core: Error handler (BE): PHP Warning: Undefined array key "title" in /var/www/html/private/typo3/sysext/backend/Classes/Form/Container/FlexFormSectionContainer.php line 82

Core: Error handler (BE): PHP Warning: Undefined array key "title" in /var/www/html/private/typo3/sysext/backend/Classes/Form/Container/OuterWrapContainer.php line 71

Core: Error handler (BE): PHP Warning: Undefined property: Causal\ImageAutoresize\Controller\ConfigurationController::$retUrl in /var/www/html/private/typo3conf/ext/image_autoresize/Classes/Controller/ConfigurationController.php line 228

Env: DDEV, PHP v8.0, TYPO3 v11.6.10

Frontend-Upload not possible

Hi,
after updating the the extension to the latest version and uploading a file in frontend the following (new) error message appears:
TypeError
Return value of Causal\ImageAutoresize\Slots\FileUpload::getBackendUser() must be an instance of TYPO3\CMS\Core\Authentication\BackendUserAuthentication, null returned.

Thanks for fixing

keep_metadata = 1

Hi Xavier!

Is it correct that keep_metadata is set 0 by default? I wasn't sure where I see it in the extension.

We had quite a session to find out not only TYPO3 strips metadata out of images, but also image_autoresize.
There is an issue with firefox that causes sRGB images without the correct color profile information to display oversaturated.

While I find it best practice to strip other maybe confidential metadata (cf. Harry Potter), I think color profiles shouldn't be stripped out by default. Or?

To avoid long debugging sessions like ours, I would propose to set keep_metadata = 1 as default value.

(same in TYPO3...: [GFX][processor_stripColorProfileByDefault] and [GFX][processor_stripColorProfileCommand], but I'll wait for your feedback to see if I should open a request on forge)

Best
Urs

`reportAdditionalStorageClaimed` does not work on read-only file-systems

We're hosting on platform.sh and the directory typo3conf/ext/ is read-only, therefore reportAdditionalStorageClaimed does not work and throws errors which are reported in the backend-log.

Core: Error handler (BE): PHP Warning: fopen(/app/web/typo3conf/.tx_imageautoresize): failed to open stream: Read-only file system in /app/vendor/typo3/cms/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 2124

It would be nice if this feature could be turned off and in addition, the path to the log-file could be configured.

release for php 7.3

I want to update to php 7.3 but the most recent release claims to mot support php 7.3 while dev-master does.

Any plans for releasing a new version?

Error saving the sheduler task

Hello

TYPO3 11

I get an error editing the scheduler task, if any of the directory fields is not validated.

Too few arguments to function TYPO3\CMS\Scheduler\Controller\SchedulerModuleController::__construct(), 0 passed in /var/www/html/web/typo3conf/ext/image_autoresize/Classes/Task/BatchResizeAdditionalFieldProvider.php on line 139 and exactly 5 expected

The reason is the new fakeSchedulerModuleController() which extends the original Module,, but the constructor is called with no argument.
Also, PSR forbids declaring two php class within one file.

In order to fix it, the BatchResizeAdditionalFieldProvider should directly use the flashMessageQueue.

TypeError: BackendUserAuthentification

When no BackendUser is logged in the FileUpload.php throws an exception.
Allthough UserGroup settings is off and the folder where the image gets uploaded in the frontend from ext:form_framework is excluded from upload check.
See attachment.
Error

Signal/slot to post-process the configuration

Hello!

Months after, i'm testing your implementation of signal/slot.

It's working, but it's not the behaviour i had in mind when i made my PR #29 at the time.

The current behaviour with the signal slot, is: when an extension connects to the signal, the configuration is always taken from the there. That mean you can't define your own configuration inside the extension manager.

What i suggest is either dispatching the signal only when the default configuration is retrieved, like this:

    /**
     * @return array
     */
    public static function readConfiguration(): array
    {
        $configurationFileName = static::getConfigurationFileName();

        $configuration = file_exists($configurationFileName) ? include($configurationFileName) : [];
        if (!is_array($configuration) || empty($configuration)) {
            $configuration = static::getDefaultConfiguration();
            $signalSlotDispatcher = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
            $signalSlotDispatcher->dispatch(
                __CLASS__,
                static::SIGNAL_ProcessConfiguration,
                [
                    'configuration' => &$configuration,
                ]
           );
        }

        return $configuration;
    }

Or dispatching another signal for this purpose only.

    const SIGNAL_ProcessDefaultConfiguration = 'processDefaultConfiguration';

    /**
     * @return array
     */
    public static function readConfiguration(): array
    {
        $configurationFileName = static::getConfigurationFileName();

        $configuration = file_exists($configurationFileName) ? include($configurationFileName) : [];
        if (!is_array($configuration) || empty($configuration)) {
            $configuration = static::getDefaultConfiguration();
            $signalSlotDispatcher = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
            $signalSlotDispatcher->dispatch(
                __CLASS__,
                static::SIGNAL_ProcessDefaultConfiguration ,
                [
                    'configuration' => &$configuration,
                ]
           );
        }

        $signalSlotDispatcher = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
        $signalSlotDispatcher->dispatch(
            __CLASS__,
            static::SIGNAL_ProcessConfiguration,
            [
                'configuration' => &$configuration,
            ]
        );

        return $configuration;
    }

This way, an extension could "propose" its own default configuration, but the admin would always have the final words on the configuration he wanted by using the extension manager.

If this is relevant to you, i can make the PR with the behaviour you like the most.

Thanks!

Image auto rotation - GraphicsMagick (one more time)

Hi,

can anyone confirm working situation with GraphicsMagick, on one site I had my hack implemented (#23) with version 1.9.1, after updating to 1.9.2 auto rotation doesn't work again.

As I see on file upload, original image is 90 CCW, after upload image is 90 CW.

Thanks.

Problems related to cropVariants

If you use image_autoresize together with cropVariants, there are problems with the selection of the crop. If you have an image with 5760 x 3840px and calculate it down to 1200 x 800, cropVariants uses the 5760 x 3840px as a starting point and calculates errors. After the conversion, the size of the picture in sys_file_metadata remains unchanged.

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.