Automatically resize images

Some days ago, I wondered whether it would be possible to hook into TYPO3’s file upload process to automatically resize pictures. Why you ask? Here is a common use-case: you would like to let your editors upload any picture they have without having to fear your fileadmin/ being invaded by 12 MP shots (4256 × 2832 pixels, ~5 MB)…

  • TYPO3 will handle such huge pictures and resize them according to our needs but it will take time to process them. Let's take a picture gallery as example. Showing 20 thumbnails per page will require TYPO3 to generate 2 versions of each file, one for the “large” version limited to 800 × 600 pixels, shown in a pretty lightbox, and the other in about 120 pixels wide as the real thumbnail. Taking quite good hardware will require some amount of RAM and many CPU cycles to process all those pictures and your gallery will simply take a huge amount of time to be rendered (when not in cache, but your cache is invalidated each night…)
  • These images, although never used in their full resolution, will eat a lot of place in your backup
  • Your editors are perhaps aware of the problem, perhaps not, but how should they deal with this problem when using computers without their preferred image editing software? During holidays for instance. After all, they want to publish information and should not be refrained to do it.
  • TYPO3 can properly resize pictures, why do not use this feature during the upload process?

As said, I searched for a possible hook to be used within TYPO3 but did not find it. Instead, by reading code, I discovered that there was a trash/recycler available but that nearly nobody was aware of (read my recent article on this topic). This is why I proposed two hooks to be added to TYPO3 and could commit them for current TYPO3 trunk, that is for upcoming TYPO3 4.5.0. I then created an extension to take advantage of them:  image_autoresize.

As I know that people running current versions of TYPO3 are likely to wish they could use this extension too, I made it compatible with TYPO3 4.3 and TYPO3 4.4 thanks to XCLASS.

Resize Images Automatically

Here are some screenshots of what the extension image_autoresize features:

Images will be resized automatically according to your configuration:

You will even be able to create complex rules based on some special directories or groups the current editor is member of.

Rule sets let you override general configuration. For instance, you may allow higher resolution pictures if they are targeted at the press (e.g., allow pictures to be as wide as 4000 px). This may either be group-related (user of group “Press and Communication” are allowed to upload such big pictures) and/or directory-related (photos uploaded in a special “press/” directory are allowed to be that large).

 

Other options (such as auto-rotating picture based on EXIF orientation) are available. Be sure to read the  manual. It will show you all features of this extension.

I’m sure you, as administrator, and your editors will enjoy this extension:

 

 

Causal Sàrl - Development, TYPO3, Consulting
Flattr