Jump to content

$config->imageSizerOptions doesn't seem to do anything?


a-ok
 Share

Recommended Posts

I've had a look at a lot of the forum posts relating to the gamma correction on images and I've followed some examples and declared this in my config file.

$config->imageSizerOptions = array(
	'upscaling' => true,
	'cropping' => true,
	'quality' => 100,
	'sharpening' => 'none',
	'defaultGamma' => -1
);

But when comparing the original uploaded image, and the resized image, it still seems to be altering the image a lot. I have even changed this directly in /wire/config.php in case it was related to my setup but this still doesn't work. You can see the difference in images here:

http://plh.dk/site/assets/files/2554/natalia-1.760x950.jpg and http://plh.dk/site/assets/files/2554/natalia-1.jpg (original)

Any thoughts? I have created new resized sizes to test (so it builds the new images based on this new config change) but, again, it doesn't seem to affect anything.

I have also set up the options directly on the usage in the template but, again, doesn't seem to affect the image (http://plh.dk/site/assets/files/2554/natalia-1.720x900.jpg).

$options = array(
	'quality' => 100,
	'sharpening' => 'none',
	'defaultGamma' => -1
);
$image = $person->contact_team_image->size(720, 900, $options);

 

Link to comment
Share on other sites

Most likely the problem is that you already have an image variation at that size that was created with different quality, sharpening, gamma, etc. Settings like that do not form part of the variation file name so you receive the existing variation rather than a new variation being created. I made a wishlist item long ago requesting better handling of this.

So you have to clear the image variations, or use the forceNew option in the $options array (just once, then remove it so you are not creating the new variation over and over again).

  • Like 1
Link to comment
Share on other sites

50 minutes ago, oma said:

I had used $image->removeVariations(); later after posting and it still didn’t help. Is this what you meant?

I was actually thinking of just manually removing the variations in Page Edit, but removeVariations() should also work (it works for me).

What about using the forceNew option? Is that working for you?

Link to comment
Share on other sites

3 hours ago, oma said:

Your original image has an AdobeRGB colour profile. Because support for colour profiles is going to vary in PHP/GD/ImageMagick and from browser to browser it would be a good idea to convert and save your images with the sRGB profile which is the mostly widely supported. This was discussed recently on the forums here:

More reading: https://fstoppers.com/pictures/adobergb-vs-srgb-3167

  • Like 2
Link to comment
Share on other sites

On 28/11/2017 at 9:13 PM, oma said:

$config->imageSizerOptions = array( 'upscaling' => true, 'cropping' => true, 'quality' => 100, 'sharpening' => 'none', 'defaultGamma' => -1 );

Maybe take a look at this thread.

It covers a bunch of stuff about image options. One of the points was not to override the imageSizerOptions like in the very top example code in this thread.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Sorry to bring this back up but I'm still fairly confused at how to resolve this.

See attached two images. One is the original uploaded and one is the resized version. I've checked the colour profile and it seems to be sRGB. I'm basically hoping that resized images are resized only (cropped) and no colour changes happen.

Any further thoughts?

jeremy-abrahams-photography-sheffield-thomas-hezekiah-goode.1600x800.jpg

 

jeremy-abrahams-photography-sheffield-thomas-hezekiah-goode.jpg

Link to comment
Share on other sites

If you click on these images you'll see the difference.

I'm also using this within my template:

$image = $images->size(1600,800, ['upscaling' => true, 'cropping' => 'center', 'quality' => 100, 'sharpening' => 'none', 'defaultGamma' => -1]); // 2:1

I have now added the below to my config.php file instead of the above and reuploaded the image but it still shows the same quality/colour loss on the resized image.

$config->imageSizerOptions['sharpening'] = 'none';
$config->imageSizerOptions['quality'] = 100;
$config->imageSizerOptions['defaultGamma'] = -1;

 

Link to comment
Share on other sites

9 hours ago, oma said:

I've checked the colour profile and it seems to be sRGB.

It's not sRGB.

2018-02-27_103735.png.2b7960d7260491cb3203ec69f9e55bae.png

Perhaps consider setting up a batch process in Photoshop to convert your supplied images to sRGB profile.

 

9 hours ago, oma said:

I have now added the below to my config.php file instead of the above and reuploaded the image but it still shows the same quality/colour loss on the resized image.


$config->imageSizerOptions['sharpening'] = 'none';
$config->imageSizerOptions['quality'] = 100;
$config->imageSizerOptions['defaultGamma'] = -1;

Setting individual imageSizerOptions in config like that doesn't work. There are two options for overriding individual options in /site/config.php...

$config->imageSizerOptions = array_merge($config->imageSizerOptions, ['upscaling' => false]);

...or...

$config->imageSizerOptions('upscaling', false);

 

  • Like 2
Link to comment
Share on other sites

2 hours ago, Robin S said:

It's not sRGB.

2018-02-27_103735.png.2b7960d7260491cb3203ec69f9e55bae.png

Perhaps consider setting up a batch process in Photoshop to convert your supplied images to sRGB profile.

 

Setting individual imageSizerOptions in config like that doesn't work. There are two options for overriding individual options in /site/config.php...


$config->imageSizerOptions = array_merge($config->imageSizerOptions, ['upscaling' => false]);

...or...


$config->imageSizerOptions('upscaling', false);

 

This is all super helpful, Robin. I think that imageSizerOption setup is working now. Hero. Thank you.

As I'd need to re-upload all these images again to get the new options... is there a good way to do this via the API?

  • Like 1
Link to comment
Share on other sites

3 hours ago, oma said:

As I'd need to re-upload all these images again to get the new options... is there a good way to do this via the API?

You can use $pageimages->add() to add images to a field.

$page->image_field->add('/full/path/to/image.jpg');

...or...

$page->image_field->add('http://domain.com/url/to/image.jpg');

But seeing as you will probably want to replace the existing image while keeping the same name you might want to use the PW admin to drop the new image onto the existing one. Not sure if there is an equivalent for doing that via the API.

  • Like 1
Link to comment
Share on other sites

7 hours ago, Robin S said:

You can use $pageimages->add() to add images to a field.


$page->image_field->add('/full/path/to/image.jpg');

...or...


$page->image_field->add('http://domain.com/url/to/image.jpg');

But seeing as you will probably want to replace the existing image while keeping the same name you might want to use the PW admin to drop the new image onto the existing one. Not sure if there is an equivalent for doing that via the API.

I guess I could use 

$image->removeVariations()

or even https://modules.processwire.com/modules/pageimage-remove-variations/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...