wp_get_image_editor makes PNG filesize larger instead of smaller
-
Hi, I’m working on a form upload image resizer based on the new wp_get_image_editor, however when I try to resize PNG images down the resulting filesize gets LARGER <?> , the resize function works fine for other mime types (gif,jpg).
Any ideas how to prevent the resized PNG’s from blowing up disproportionally ?? (going from a 960x800px 117 Kb -> 680x~560px -> 262 Kb )
Here’s my code snippet :
function resize_680($imfile = '') { if (strlen($imfile) < 6) return false; if (!is_writable($imfile)) return false; list($width, $height, $type, $attr) = @getimagesize($imfile); if ($width < 680) return false; $newsize = wp_constrain_dimensions( $width, $height, 680, 680 ); $image = wp_get_image_editor( $imfile ); if ( ! is_wp_error( $image ) ) { $image->resize( $newsize[0],$newsize[1], true ); $image->save( $imfile ); } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘wp_get_image_editor makes PNG filesize larger instead of smaller’ is closed to new replies.