protected function _save( $image,
$filename = null,
$mime_type = null
) { list
( $filename,
$extension,
$mime_type ) =
$this->
get_output_format( $filename,
$mime_type );
if ( !
$filename ) { $filename =
$this->
generate_filename( null, null,
$extension );
} if ( 'image/gif' ===
$mime_type ) { if ( !
$this->
make_image( $filename, 'imagegif', array
( $image,
$filename ) ) ) { return new WP_Error( 'image_save_error',
__( 'Image Editor Save Failed'
) );
} } elseif ( 'image/png' ===
$mime_type ) { // Convert from full colors to index colors, like original PNG.
if ( function_exists( 'imageistruecolor'
) && !
imageistruecolor( $image ) ) { imagetruecolortopalette( $image, false,
imagecolorstotal( $image ) );
} if ( !
$this->
make_image( $filename, 'imagepng', array
( $image,
$filename ) ) ) { return new WP_Error( 'image_save_error',
__( 'Image Editor Save Failed'
) );
} }