resample( $width, $height ); if ( $crop_w && $crop_h ) { $centreX = round( $img -> getWidth() / 2 ); $centreY = round( $img -> getHeight() / 2 ); $x1 = $centreX - $crop_w / 2; $y1 = $centreY - $crop_h / 2; $x2 = $centreX + $crop_w / 2; $y2 = $centreY + $crop_h / 2; $img -> crop( $x1, $y1, $x2, $y2 ); } $img -> save( '../' . $cache_dir . $img_md5 ); chmod( '../' . $cache_dir . $img_md5, 0755 ); } header( 'Cache-Control: public' ); header( "Content-type: image/jpeg" ); readfile( '../' . $cache_dir . $img_md5 );