Project

General

Profile

Actions

Bug #46728

closed

ADJUST in GIFBUILDER not working as documented

Added by Den Denyer about 11 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-03-27
Due date:
% Done:

50%

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

Description

Hi Guys,

Referencing bug #13724, I am the one guy on the internet trying to use ADJUST in his GIFBUILDER objects, only to discover it doesn't work if implemented as documented.

My extension code is as follows:

        $image = array();
        $image['10'] = "IMAGE";
        $image['10.']['file'] = 'GIFBUILDER'; 
        $image['10.']['file.']['format'] = 'jpg';
        $image['10.']['file.']['XY'] = "{$conf['width']},{$conf['height']}";
        $image['10.']['file.']['backColor'] = '#ffffff';

        $image['10.']['file.']['10'] = 'IMAGE';
        $image['10.']['file.']['10.']['file'] = 'uploads/pics/'.$row['image'];
        $image['10.']['file.']['10.']['file.']['XY'] = '[10.w],[10.h]';
        $image['10.']['file.']['10.']['file.']['width'] = ($conf['width']-20);
        $image['10.']['file.']['10.']['align'] = 'c,c';
        $image['10.']['file.']['20'] = 'ADJUST';
        $image['10.']['file.']['20.']['value']= 'inputLevels = 0, 200';

I tried various permutations of the value, nothing seemed to work. When I swapped it out for an EFFECT (gamma) it worked just fine, so my conclusion is the ADJUST is broken.

I went digging into the source and ended up at inputLevels() in the stdgraphics lib code. Here it seems that the following is called:

(Code here: https://github.com/TYPO3/TYPO3v4-Core/blob/master/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php#L1957 )

$totalCols = ImageColorsTotal($im);

This returns 0 on true-colour images, which then fails to perform any adjustments.

Might be worth mentioning in the docs that this is not suitable for 256 colour images, and/or get someone smarter than me to make it work with any supplied image! :D

(Also I couldn't find the relevant tracker to add this to as a code bug, which is why it's here in the TS Ref tracker. Please move / repost / let me know which group is correct for this!)

Actions #1

Updated by Chris topher about 11 years ago

Hi Den,

ahh, you are the one. ;-)

Here is the documentation of ADJUST.

ImageColorsTotal($im) returns 0 on true-colour images, which then fails to perform any adjustments.

The PHP manual says: "ImageColorsTotal returns the number of colors in the specified image's palette or 0 for truecolor images".

We could now document, that you cannot adjust truecolor images, ;-) but:

Was that the intention, when the code was written? Should adjustment of images be impossible, when/because they are truecolor images? I don't think so...

Actions #2

Updated by Den Denyer about 11 years ago

  • % Done changed from 0 to 50

Weeeell, to be honest a levels adjust on a 256 colour image is a bit poor anyway, as far as I'm concerned the expectation is that any adjustments or filters available should work on any supplied raster image.

The odd thing, is that levels are available in IM, perhaps they were not when the original was conceived I'm unsure.

Anyway, you can supply:

-level black_point{,white_point}{%}{,gamma}

Which will essentially perform an input level expansion, EG if you supply "10%,90%" then levels at the 10% low end will be pushed black and 90% high end pushed white. The 3rd parameter allows for a midpoint offset. If you supply without the % then it'll take 8-bit channel values.

SOoo, I chucked this onto function IMparams($setup)

                                case 'level':
                                        $params = t3lib_div::trimExplode(',', $value,3);
                                        if (isset($params[1])) {
                                                $lower = t3lib_div::intInRange($params[0],0,100);
                                                $upper = t3lib_div::intInRange($params[1],0,100);
                                                $gamma = 1;
                                                if (isset($params[2])) {
                                                        $gamma = $gamma > 100 ? 100 : (float) $params[2];
                                                }
                                                $commands .= ' -level ' . $lower . '%,' . $upper . '%,' . $gamma;
                                        }
                                break;

For me on 4.5 it was in class.t3lib_stdgraphic.php, but I think in 6.x it's found in sysext\core\classes\Imaging\GraphicalFunctions.php and would need to be as follows:

                                case 'level':
                                        $params = explode(',', $value,3);
                                        if (isset($params[1])) {
                                                $lower = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(trim($params[0]),0,100);
                                                $upper = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(trim($params[1]),0,100);
                                                $gamma = 1;
                                                if (isset($params[2])) {
                                                        $gamma = $gamma > 100 ? 100 : (float) $params[2];
                                                }
                                                $commands .= ' -level ' . $lower . '%,' . $upper . '%,' . $gamma;
                                        }
                                break;

I'd make a patch, but I honestly have no idea how. Who should this be referred to to get it checked for submission / how would I go about proposing this?

Cheers!
Denyer

Actions #3

Updated by Den Denyer about 11 years ago

I should add that this would be an extension in the documentation to "EFFECT" and usage parameters would be:

.10 = EFFECT
.10.value = level=[0-100],[0-100]{,[0.0-100.0]}   

(That is, int lower%,int upper%,float gamma)

Actions #4

Updated by Den Denyer about 11 years ago

While we're on a roll, why don't we chuck auto-level in as well? :)

                                case 'autolevel':
                                        $commands .= ' -auto-level';
                                break;

Actions #5

Updated by Gerrit Code Review about 11 years ago

  • Status changed from New to Under Review

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at https://review.typo3.org/19458

Actions #6

Updated by Den Denyer about 11 years ago

If someone verifies this for 4.7 I can make the 6.x patch/git commit too.

Actions #7

Updated by Chris topher about 11 years ago

Hi Den, please see the comments in Gerrit.

You should continue by pushing the change for the master branch. :-)

Actions #8

Updated by Chris topher about 11 years ago

What I don't understand is: You say that ADJUST is broken. Why do you then add code to EFFECT? I would have expected that you change the code of ADJUST. As far as I see, ADJUST does not use the function IMparams(), which you are changing, so that ADJUST won't be fixed by your change.

Actions #9

Updated by Chris topher about 11 years ago

  • Project changed from 1112 to TYPO3 Core
Actions #10

Updated by Wouter Wolters over 9 years ago

  • Status changed from Under Review to Needs Feedback
  • TYPO3 Version set to 6.2
  • Is Regression set to No

Hi,

as this issue is very old. Is this feature missing in newer versions of TYPO3 CMS (6.2.9)?
If yes, can you provide a newer patch against master by using Gerrit? http://wiki.typo3.org/CWT

Actions #11

Updated by Alexander Opitz almost 9 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions

Also available in: Atom PDF