Issue Feature Closed

#64158A faster way to generate GIFBUILDER short MD5 hash inside a filename

Christian Stern 01/07/15, 12:47 updated 03/19/22, 14:01

Description

It all started with not acceptable filenames during image-generation on a multi language website, after migration to 6.2.. The filename_syntax in 4.5 was: typo3temp/GB/i_{somestrings}_1a37d4a2d0.jpg

This syntax was the same on each language, thus an image is only created once for every language. In 6.2 every image receives a different hash after image_creation. After digging into typo3/sysext/frontend/Classes/Imaging/GifBuilder.php I would like to see one of the following possibilities.

Why I received a different hash per language:

Inside $this->setup there is a huge array (72k lines). This array gets serialized. The hash is generated out of the serialized array. Inside this array sys_langauge_uid exist. Thus the hash is not the same.

Possible Features / Fixes:

  • move the existing hook (gifbuilder-ConfPreProcess) to later moment during image generation and make $this->setup accessible. So I can mess around inside this hook and remove the BBOX from $this->setup.
  • add a new hook to image-processing to access the filename/hash generation (more flexibility on image filename generation could be a nice feature)
  • create the hash out image related configurations only

I did some tests inside GifBuilder.php

I created an array out of image related configs only. This array gets serialzied to build the hash inside an image filename:

$arrayToBeSerilized = array(
    array_keys($this->setup),
    $meaningfulPrefix,
    $this->im,
    $this->w,
    $this->h,
    $this->map,
    $this->workArea,
    $this->combinedTextStrings,
    $this->combinedFileNames,
    $this->data
);

GeneralUtility::shortMD5(serialize($arrayToBeSerilized));

This array will always build different hashes for every image in any constellation, afaik.

I also did some small time measurements during the hash-generation:

Average of hash-generation with $this-setup
~ 0.00049 seconds

Average of hash-generation with image related configs only
~ 0.000019 seconds

Reviews 1