Jump to content

JPEG artifacts — no matter what quality


dreerr
 Share

Recommended Posts

Attached you see a comparison of a JPG I uploaded and one time applied ['quality'=>75] compared to ['quality'=>100] in the file size the files are 38KB resp. 245KB but on both you can find these artifacts in the blue and red parts of the image. Any idea to avoid them or try a different method of resizing?

Thanks, D.

Bildschirmfoto 2017-12-03 um 23.20.14.png

mg_7151_c_mariokiesenhofer-srgb-ORIGINAL.jpg

Link to comment
Share on other sites

9 hours ago, PWaddict said:

@dreerr I had a similar problem in the past and I fixed it by disabling the gamma correction.

On your site/config.php add this:


$config->imageSizerOptions = array(
	'defaultGamma' => -1, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0)
);

 

this is really a bad idea! with this, you wibes out all other properties of the imgaeSizerOptions:

before your correction, the imageSizerOptions array contain items for sharpening, quality gamma etc. After your correction, the defaultGamma is the only one item. All others are wiped out!

PLEASE, repeat all other items with there respective values, or use array_merge() !!

$config->imageSizerOptions = array_merge(
	$config->imageSizerOptions,   // all items from wire/config
	array(                        // overwrite specific items
		'defaultGamma' => -1,
        'sharpening' => 'medium'
	)
);

 

--------

 

But in @dreerr s case, I can't think of that this is the issue / solution. Disabling "defaultGamma" is usefull if you gets clippings in dark to black regions.

According to what @dreerr describes, my first question is: "How does the original image looks like?" If this already has arctefacts, you ever will get artefacts also in quality 100.

Where does the source- or master image comes from?

What processes gets it passed through before the upload to PW?

Any restrictions on upload? (max size?)

Maybe you can provide a link to that image online, or via PM to me?

  • Like 4
Link to comment
Share on other sites

11 hours ago, adrian said:

If you have imagick available on your server, please try installing the core module: ImageSizerEngineIMagick and if that helps.

This is what I'd try. I've had this problem in the past, but honestly never did anything about it. The next time I see this happen, I'm going to try imagemagick.

It seems that GD makes colour bands when it processes the image, which sucks. It depends on the image, if there's a smooth gradient, you'll see it.

Link to comment
Share on other sites

@horst Actually this is how I have it. Is this really bad?

$config->imageSizerOptions = array(
	'cropping' => 'north', // Crop North (top), may also be just "n".
	'sharpening' => 'none', // sharpening: none | soft | medium | strong
	'quality' => 80, // quality: 1-100 where higher is better but bigger
	'defaultGamma' => -1, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0)
);

On my previous post I left only defaultGamma just to see @dreerr the actual value I used to fix the problem.

Link to comment
Share on other sites

On 12/4/2017 at 1:44 PM, PWaddict said:

@horst Actually this is how I have it. Is this really bad?

$config->imageSizerOptions = array(
	'cropping' => 'north', // Crop North (top), may also be just "n".
	'sharpening' => 'none', // sharpening: none | soft | medium | strong
	'quality' => 80, // quality: 1-100 where higher is better but bigger
	'defaultGamma' => -1, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0)
);

On my previous post I left only defaultGamma just to see @dreerr the actual value I used to fix the problem.

 

If you have an array from wire/config.php like the imageSizerOptions:

$config->adminThumbOptions = array(
	'width' => 0, // max width of admin thumbnail or 0 for proportional to height (@deprecated, for legacy use)
	'height' => 100, // max height of admin thumbnail or 0 for proportional to width (@deprecated, for legacy use)
	'gridSize' => 130, // Squared grid size for images (replaces the 'width' and 'height' settings) 
	'scale' => 1, // admin thumb scale (1=allow hidpi, 0.5=always hidpi, 1.0=force non-hidpi)
	'upscaling' => false,
	'cropping' => true,
	'autoRotation' => true, // automatically correct orientation?
	'sharpening' => 'soft', // sharpening: none | soft | medium | strong
	'quality' => 90,
	'suffix' => '', 
	);

and you then attach a new array to $config->imageSizerOptions with a smaller set of key/value pairs, you wipe out: width, height, gridSize, scale, upscaling, autoRotation, suffix.

 

 

Besides using PHP function array_merge, you also may use this to override your desired keys without deleting the others: (THE FOLLOWING IS WRONG)

Spoiler
$config->imageSizerOptions['cropping'] = 'north';
$config->imageSizerOptions['sharpening'] = 'none';
$config->imageSizerOptions['quality'] = 80;
$config->imageSizerOptions['defaultGamma'] = -1;

 

  • Like 1
Link to comment
Share on other sites

2 hours ago, horst said:

Besides using PHP function array_merge, you also may use this to override your desired keys without deleting the others:


$config->imageSizerOptions['cropping'] = 'north';
$config->imageSizerOptions['sharpening'] = 'none';
$config->imageSizerOptions['quality'] = 80;
$config->imageSizerOptions['defaultGamma'] = -1;

 

You would think this would work, but if you test it I think you'll find that individual keys set like this have no effect.

However, Ryan recently alerted me to this working alternative for setting individual keys:

$config->imageSizerOptions('cropping', 'north');

 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Yes, with the single version I was wrong. (Should not answer without testing, when its late and I'm tired)

The only solutions to override single properties without dropping others, is ryans method or array_merge().

 

  • Like 1
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...