• whenever i upload any image and have the thumbnail displayed, the jpeg compression appears to be around 40 or something like that.

    it looks nasty.

    what’s the file i can edit in order to adjust the compression?

    i’ll post samples on my site: http://grizzlyelephant.com

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The default is actually 75. The quality difference you see is more likely due to the image resizing algorithm that the PHP/GD library has (which is only bilinear, I think).

    If you look in admin-functions.php, and look for function wp_create_thumbnail, this is where it’s making the thumbnail file.

    Scroll down and you’ll see this code:

    // move the thumbnail to its final destination
    if ( $type[2] == 1 ) {
    	if (!imagegif( $thumbnail, $thumbpath ) ) {
    		$error = __( "Thumbnail path invalid" );
    	}
    }
    elseif ( $type[2] == 2 ) {
    	if (!imagejpeg( $thumbnail, $thumbpath ) ) {
    		$error = __( "Thumbnail path invalid" );
    	}
    }
    elseif ( $type[2] == 3 ) {
    	if (!imagepng( $thumbnail, $thumbpath ) ) {
    		$error = __( "Thumbnail path invalid" );
    	}
    }

    This is where it saves the thumbnail file. Note this line:
    if (!imagejpeg( $thumbnail, $thumbpath ) ) {

    That saves the image to a jpg file if needed. No quality is specified, so it’s using the default of 75.

    To change it, edit that line like so:
    if (!imagejpeg( $thumbnail, $thumbpath, 80 ) ) {

    Where 80 is whatever compression you want (0-100).

    Thread Starter hmccorkle

    (@hmccorkle)

    Thank you. So. Much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Nasty JPEG Compression (NOT related to header)’ is closed to new replies.