Ticket #13461: 13461.2.patch
File 13461.2.patch, 2.4 KB (added by , 12 years ago) |
---|
-
wp-includes/media.php
395 395 /** 396 396 * Scale down an image to fit a particular size and save a new copy of the image. 397 397 * 398 * The PNG transparency will be preserved using the function, as well as the398 * The PNG and GIF transparency will be preserved using the function, as well as the 399 399 * image type. If the file going in is PNG, then the resized image is going to 400 400 * be PNG. The only supported image types are PNG, GIF, and JPEG. 401 401 * … … 430 430 return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); 431 431 list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; 432 432 433 $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h );433 $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h, $orig_type, $image ); 434 434 435 435 imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); 436 436 … … 1019 1019 * 1020 1020 * @param int $width Image width 1021 1021 * @param int $height Image height 1022 * @param int $image_type Image type 1023 * @param resource $original_image Original image 1022 1024 * @return image resource 1023 1025 */ 1024 function wp_imagecreatetruecolor($width, $height) { 1025 $img = imagecreatetruecolor($width, $height); 1026 if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) { 1027 imagealphablending($img, false); 1028 imagesavealpha($img, true); 1026 function wp_imagecreatetruecolor( $width, $height, $image_type = null, $original_image = null ) { 1027 $img = imagecreatetruecolor( $width, $height ); 1028 if ( ! is_resource( $img ) ) 1029 return false; 1030 1031 if ( IMAGETYPE_GIF == $image_type && is_resource( $original_image ) && function_exists( 'imagecolortransparent' ) ) { 1032 $transparent_id = imagecolortransparent( $original_image ); 1033 if ( $transparent_id >= 0 ) { 1034 $transparent_color = imagecolorsforindex( $original_image, $transparent_id ); 1035 $transparent_id = imagecolorallocate( $img, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue'] ); 1036 imagefill( $img, 0, 0, $transparent_id ); 1037 imagecolortransparent( $img, $transparent_id ); 1038 } 1039 } elseif ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { 1040 imagealphablending( $img, false ); 1041 imagesavealpha( $img, true ); 1029 1042 } 1043 1030 1044 return $img; 1031 1045 } 1032 1046