Opened 13 years ago
Closed 13 years ago
#19679 closed enhancement (wontfix)
Quicker image compression
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3 |
Component: | Media | Keywords: | has-patch close |
Focuses: | Cc: |
Description
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); } }
Change History (5)
#2
in reply to:
↑ 1
@
13 years ago
Replying to scribu:
I'm not so sure the image quality would always be the same.
But the real deal breaker is that intermediate image sizes aren't always sortable, i.e. you can have a 400x600 size and a 600x400 size. Not to mention cropping.
Of course! Bit too quick here.. I was thinking of crop earlier, but forgot it during the process of coding..
BWhat about using the large one, instead of the original one if the resolution is quite different? A 8mpx image is far from a 2mpx in process time.. :)
My multisite users often complain about long image processing time, but maybe this is unique for my site?
I'm not so sure the image quality would always be the same.
But the real deal breaker is that intermediate image sizes aren't always sortable, i.e. you can have a 400x600 size and a 600x400 size. Not to mention cropping.