modxcms / pThumb

A better phpThumbOf
46 stars 28 forks source link

Adding background color to transparent png and output format jpg #44

Open labr1005 opened 8 years ago

labr1005 commented 8 years ago

Can you confirm that it's really not possible to add a background color to a transparent png and change the output format to jpg?

On the phpthumb demo page it works... http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php#x9

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000`]]

Result: red background, png. Close, but still a (large) png.

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000&f=jpg`]]

Result: black background, jpg.

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000` &useResizer=`0`]]

Result: cropped image (squared, ???), white background, png.

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000&f=jpg` &useResizer=`0`]]

Result: cropped image (squared, ???), white background, jpg.

labr1005 commented 8 years ago

Doing it in 2 steps seems to work, nesting or using toPlaceholder. But this just doesn't feel right...

[[phpthumbof? &input=`[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000`]]` &options=`f=jpg`]]
[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000` &toPlaceholder=`imageWithBg`]]
[[phpthumbof? &input=`[[+imageWithBg]]` &options=`f=jpg`]]
labr1005 commented 6 years ago

I tracked this one down to this line: https://github.com/modxcms/Resizer/blob/master/core/components/resizer/model/vendor/oo12/reductionist/src/Reductionist/Reductionist.php#L411

The check for !$outputIsJpg prevents the creation of a jpg with a background color.

But why?