Image scaling for product images

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Dennis
Posts: 15
Joined: 30 Nov 2016, 09:16

Image scaling for product images

Post by Dennis » 13 Nov 2017, 11:09

Hi,

as you know, the starting point for the image scaling of product images is the scheduler task "Rescale product images". This task leads to calling the method imagescale within the file typo3conf/ext/aimeos/Resources/Libraries/aimeos/aimeos-core/lib/mwlib/src/MW/Media/Image/Standard.php.

In this context, we have experienced in our system that calling the method imagescale within the method public function scale( $width, $height, $fit = true ) within typo3conf/ext/aimeos/Resources/Libraries/aimeos/aimeos-core/lib/mwlib/src/MW/Media/Image/Standard.php leads to bad quality and a thin black border (to the right and to the bottom). See https://github.com/aimeos/aimeos-core/b ... d.php#L164, please, for the concrete line in the code.

Calling the resample method instead (https://github.com/aimeos/aimeos-core/b ... d.php#L172) leads in our case to much better results.

Therefore, I have the following questions: Do you or some of your customers have experienced similar things concerning the image scaling? Can you imagine some reasons why our results are so bad? Wouldn't it be better to use the resample method resulting in better results? Maybe a configuration option to choose between different image scaling methods could be nice, too.

Besides, I have another question concerning overwriting the core file for the image scaling. I tried to overwrite the core file typo3conf/ext/aimeos/Resources/Libraries/aimeos/aimeos-core/lib/mwlib/src/MW/Media/Image/Standard.php with a file/class within our custom aimeos extension : withtypo3conf\ext\ourextensionkey\Resources\Private\Extensions\ourextensionkey\lib\custom\src\MW\Media\Image\Customized.php. However, no TypoScript configuration worked so far so that the Customized class was taken instead the Standard class. Is it possible to overwrite the Standard class and how would the TypoScript configuration look like?
(plugin.tx_aimeos.settings.mw.media.image.name = Customized or mw.media.image.name = Customized didn't work so far)

Many thanks for your help in advance!

TYPO3 8.7.7. aimeos 17.10.0, PHP: 7.0.25-1~dotdeb+8.1, Operating system: Unix

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Image scaling for product images

Post by aimeos » 13 Nov 2017, 15:29

The "Rescale product images" job is only for rescaling if you changed the frontend and need now preview images of different sizes. Product images can be already scaled on upload if you configure this:
- https://aimeos.org/docs/Configuration/C ... s/maxwidth
- https://aimeos.org/docs/Configuration/C ... /maxheight

If the quality of the resample method is higher than the imagescale() method, we should remove it in favor of resampling. Are you able to create a pull request on Github for this?

GDLib is known for worse results than e.g. Imagemagick. Therefore, there's an alternative implementation of the media image class called "Imagick" which you can use if your server has installed Imagemagick:
https://aimeos.org/docs/Configuration/C ... rd/options

The configuration for this must be:

Code: Select all

['image' => ['name' => 'Imagick']]
We've updated the documentation in the code so this will be added to the configuration description next time:
https://github.com/aimeos/aimeos-core/c ... 0195347134
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Dennis
Posts: 15
Joined: 30 Nov 2016, 09:16

Re: Image scaling for product images

Post by Dennis » 16 Nov 2017, 13:02

Thank you!

The rescaling when uploading works when having the following configuration, for example (as you mentioned):

module.tx_aimeos.settings.controller.common.media.standard.preview.maxwidth = 620
module.tx_aimeos.settings.controller.common.media.standard.files.maxwidth = 1024

You are totally right. I had a bad configuration that did not work.

I will deal with the other things a bit later, but tell you then. :) Thank you for the advice concerning the configuration.

stiller
Posts: 83
Joined: 05 Mar 2016, 15:59

Re: Image scaling for product images

Post by stiller » 23 Aug 2018, 19:12

hi there.

stumpled upon this thread as I'm experiencing the issue with black borders (right and bottom) as well.
is this the right scheduler typoscript to switch to imagemagick?

Code: Select all

controller.common.media.standard.options.image {
name = Imagick
jpeg.quality = 80
}
any other settings available?

@Dennis: how exactly did you solve the black border issue?

cheers
Volker

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Image scaling for product images

Post by aimeos » 23 Aug 2018, 19:28

The black borders are sometimes produced by GD and if you switch to Imagemagick, the problem should go away. The correct quality setting is

Code: Select all

controller.common.media.standard.options.image {
    name = Imagick
    quality = 80
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply