Can WordPress resize BMP files?

Interesting situation i just ran into.

I have a site I am developing in which I have defined specific image sizes I want created whenever a new image is uploaded. Currently lets just say that I defined a specific thumbnail size of 75×75 and a medium sized image of 150×150 pixels.

Read More

Assuming we proceed to upload a new image using the built in media uploader we would expect that WordPress will automatically upload and store the original image along with any additional images sizes which I have specified in my functions.php file (in this case the 75×75 and 150×150 pixel images).

First of all, the above illustrated example is indeed working perfectly and I am very happy with the results.

What I have noticed though is that when you pick a bmp file to upload the automatic resizing does not take place.

My objective here is to figure out who else might have noticed this issue while attempting to find a solution for this problem. I need to ensure that even when a large bmp file is uploaded that the code

the_post_thumbnail( array(50,50), 'class=alignleft' );

will show the 50×50 pixel image.

Just in case anyone is interested, I have confirmed this issue is specifically related to bmp image by taking the original bmp image and saving it as a jpg and png file through photoshop and then using the wordpress media manager to upload the same files converted by photoshop… In both cases I noticed that after uploading each converted file the exact same images WERE correctly being resized.

I should also point out that when a bmp file image was uploaded the actual upload of that file DID take place however in the media manager only the original (full size) image was available to insert into posts and checking the media upload folder also only showed a single image.

Any guidance, help or diagnosis is greatly appreciated!

Related posts

Leave a Reply

2 comments

  1. No, wordpress can not resize BMP files. Beware that it does not make sense to use BMP files in a website because a broad number of webbrowsers is not able to display them.

    Filetypes that are supported by WordPress and which are widely supported by internet browsers are: GIF, JPG and PNG.

    Those formats are optimized for internet use as they compress image data. BMP is a common image format but not in the internet because it has large file sizes.

  2. This is from another thread, with code that lets you limit the filetypes you allow.

    add_filter('wp_handle_upload_prefilter', 'yoursite_wp_handle_upload_prefilter');
    function yoursite_wp_handle_upload_prefilter($file) {
    // This bit is for the flash uploader
    if ($file['type']=='application/octet-stream' && isset($file['tmp_name'])) {
    $file_size = getimagesize($file['tmp_name']);
    if (isset($file_size['error']) && $file_size['error']!=0) {
      $file['error'] = "Unexpected Error: {$file_size['error']}";
      return $file;
    } else {
      $file['type'] = $file_size['mime'];
    }
    }
    list($category,$type) = explode('/',$file['type']);
    if ('image'!=$category || !in_array($type,array('jpg','jpeg','gif','png'))) {
    $file['error'] = "Sorry, you can only upload a .GIF, a .JPG, or a .PNG image file.";
    } else if ($post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : false)) {
    if (count(get_posts("post_type=attachment&post_parent={$post_id}"))>0)
      $file['error'] = "Sorry, you cannot upload more than one (1) image.";
    }
    return $file;
    }
    

    The code is by MikeSchinkel