Project

General

Profile

Actions

Bug #19751

closed

Strip uploaded images headers

Added by John Angel over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Priority:
Should have
Category:
Content Rendering
Target version:
-
Start date:
2008-12-28
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.2
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Images can hold miscellaneous information (profiles, comments) in its headers.

The idea is to introduce config option:

$TYPO3_CONF_VARS['GFX']['im_strip_uploaded_images'] = 1;

which would strip such headers from images when uploading them to Typo3.

Since ImageMagick cannot strip headers without recompressing the image (http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=10895&start=0&st=0&sk=t&sd=a), we should use 'jpegtran' command (part of libjpeg package for lossless transformation) for jpegs and im 'convert' for other formats:
- Command for jpegs: jpegtran optimize -copy none -outfile out.jpg in.jpg
Command for other formats: convert -strip in.png out.png
And then replace the original image if the resulting is smaller.

Please find attached shell script for stripping existing images. The same logic should be implemented in Typo3 itself, triggered on every image upload.

You can try the script using 'test' switch:
./strip_image_headers.sh test /typo3/typo3temp

I would recommend running the following commands on the existing Typo3 installation (backup everything first of course):

./strip_image_headers.sh typo3temp
./strip_image_headers.sh typo3temp/pics
./strip_image_headers.sh uploads
./strip_image_headers.sh uploads/pics
./strip_image_headers.sh uploads/media

and for all other directories where you have uploaded your own images.

You can later fix ownership of files if necessary.

Statistics for 96187 images:
- Before: 2176 MB
- After running the script: 1243 MB
- Gain: 43% smaller images!

Related to #19748.

(issue imported from #M10032)


Files

strip_image_headers.sh (1.5 KB) strip_image_headers.sh Administrator Admin, 2008-12-28 23:08
strip_image_headers2.sh (1.84 KB) strip_image_headers2.sh Administrator Admin, 2008-12-29 22:31
Actions

Also available in: Atom PDF