[wp-trac] [WordPress Trac] #19679: Quicker image compression
WordPress Trac
wp-trac at lists.automattic.com
Wed Dec 28 18:30:16 UTC 2011
#19679: Quicker image compression
--------------------------+-----------------------------
Reporter: mariusmandal | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.3
Severity: normal | Keywords: has-patch
--------------------------+-----------------------------
When uploading a 8MB photo, WP used 12 seconds to compress the image to 4
sizes. After a quick mod, it uses 4 seconds to do the same job, without
any noticable image quality loss (even though there is a small theoretical
one)
Shortly put:
Sort sizes by area from large to small, and always create <this size> from
the last image.
(the image size sorting might be done better, without me knowing how to at
the moment..)
Why not do it like this? :)
My modifications to wp-admin/includes/image.php, replacing line 122-128 :
{{{
foreach($sizes as $size => $info) {
$newsizes[ $info['width']*$info['height'] ] = $info;
$sizename[ $info['width']*$info['height'] ] = $size;
}
krsort($newsizes);
foreach($newsizes as $res => $info)
$sizes[$sizename[$res]] = $info;
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
foreach ($sizes as $size => $size_data ) {
$resized = image_make_intermediate_size( $file,
$size_data['width'], $size_data['height'], $size_data['crop'] );
if ( $resized ) {
$metadata['sizes'][$size] = $resized;
$file = str_replace(substr($file, strrpos($file,'.')),
'-'.$resized['width'].'x'.$resized['height'].substr($file,
strrpos($file,'.')),
$file);
}
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19679>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list