Jump to content

Force progressive JPG


Peter Knight
 Share

Recommended Posts

Is there a way to make JPGs progressive by default via the API?

I've added the following to my site/config.php file but user-uploaded images are often displayed as non progressive.

$config->imageSizerOptions = array(
	'upscaling' => true, // upscale if necessary to reach target size?
	'cropping' => true, // crop if necessary to reach target size?
	'autoRotation' => true, // automatically correct orientation?
	'interlace' => true, // use interlaced JPEGs by default? (recommended)
	'sharpening' => 'soft', // sharpening: none | soft | medium | strong
	'quality' => 95, // quality: 1-100 where higher is better but bigger
	'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images
	'defaultGamma' => 0.5, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0)
	);

Thanks

Link to comment
Share on other sites

15 minutes ago, wbmnfktr said:

I guess I'm totally wrong with that but somehow my mind tells me that you will need ImageMagick/IMagick support for this.

 

Apparently not! This is the file for the GD engine, found it in the github issues where where this feature was being discussed and @horst published changes for both GD and imagemagick engines.

https://github.com/horst-n/processwire/blob/f072a52ccec7ffadd6831b5002ebd0b569274216/wire/core/ImageSizerEngineGD.php#L286

But maybe GD needs something else (some config?) to support it??

Link to comment
Share on other sites

22 minutes ago, Autofahrn said:

Probably totally stupid question, but do the user-uploaded images go through PW-side image processing at all?

I have some width and height restrictions on my images field so the image gets uploaded and resized. In this case I'd assume anything specified in the 

Quote

$config->imageSizerOptions = array(

gets applied. But i'm only guessing.

  • Like 1
Link to comment
Share on other sites

7 hours ago, Autofahrn said:

Probably totally stupid question, but do the user-uploaded images go through PW-side image processing at all?

You can learn about it in this post: 

 

Also note that since ProcessWire 3.0.63 client-side resize gives us another option in the mix https://processwire.com/blog/posts/processwire-3.0.63-adds-client-side-image-resizing/

So it all depends on how you set it up and implement it. It is possible to serve unaltered images if you make sure PW does not touch it in the first place. However, it is only recommended for tech tech-savvy users or for special use cases.

Edited by szabesz
typo
Link to comment
Share on other sites

4 minutes ago, szabesz said:

You can learn about it in this post:

yup, it says

Quote

the original uploaded files never get altered

So if an image is simply uploaded and downloaded without manipulation (i.e. sizing), the original, unaltered version should be retrieved. At least that's the case in all my setups.

  • Like 1
Link to comment
Share on other sites

5 minutes ago, Autofahrn said:

yup, it says

Quote

the original uploaded files never get altered

However, there are exceptions as noted ? the max size image imagefiled constrain and/or client-side image resizing might result in having a different file stored instead of the original supplied.

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

×
×
  • Create New...