Page 1 of 1

Thumbnail not created for .bmp images

Posted: Thu Dec 15, 2005 11:03 am
by sweety
hi all,
I am not able to upload .bmp images properly into my blogs.If it is a very large image then the entire page layout is getting changed.
I checked in my physical folder and found out that thumbnails are not getting created for .bmp images.Why is it so?
for any image "imagename.serendipityThumb.extension" is getting created once we upload images through Add Media.But for .bmp images they are not getting created. I saw in functions_images.inc.php file and found the following code:

Code: Select all

function serendipity_functions_gd($infilename) {
    if (!function_exists('imagecopyresampled')) {
        return false;
    }

    $func = array();
    $inf  = pathinfo(strtolower($infilename));
    switch ($inf['extension']) {
    case 'gif':
        $func['load'] = 'imagecreatefromgif';
        $func['save'] = 'imagegif';
        break;

    case 'jpeg':
    case 'jpg':
    case 'jfif':
        $func['load'] = 'imagecreatefromjpeg';
        $func['save'] = 'imagejpeg';
        break;

    case 'png':
        $func['load'] = 'imagecreatefrompng';
        $func['save'] = 'imagepng';
        break;
there is no case for 'bmp' also in this code:

Code: Select all

function serendipity_guessMime($extension) {
    $mime = '';
    switch (strtolower($extension)) {
        case 'jpg':
        case 'jpeg':
            $mime = 'image/jpeg';
            break;

        case 'aiff':
        case 'aif':
            $mime = 'audio/x-aiff';
            break;

        case 'gif':
            $mime = 'image/gif';
            break;

        case 'bmp':
             $mime='image/bmp';
             break;

        case 'png':
            $mime = 'image/png';
            break;

        case 'pdf':
            $mime = 'application/pdf';
            break;
.......
there is no case for 'bmp'..
do i have to add anything here for thumbnails to be created for .bmp images?
Can anyone please help me in solving my problem?
Thanking you in advance

Re: Thumbnail not created for .bmp images

Posted: Thu Dec 15, 2005 11:19 am
by garvinhicking
You shouldn't use BMP images in web-context.

Regards,
Garvin

Posted: Mon Dec 19, 2005 12:36 pm
by sweety
hi garvin,
Thank you so much for your reply.
Can I know why .bmp images cannot be created in web context?
I actually want images of any extension to be uploaded in my application.This is a high priority requirement.
Can you please suggest me any solution to my requirement?

Thanking you in advance,

Regards
sweety

Posted: Mon Dec 19, 2005 1:10 pm
by garvinhicking
1. BMP Images are not parsed by every OS. Linux and MacOS doesn't like it. BMP is a windows format.

2. BMP Images are badly compressed and are much too large

3. Displaying BMPs in Browsers often fails, because they have no rendering engine for BMPs.

You should always use PNG images, which is in every case the superior format.

AFAIK PHP doesn't offer BMP conversion facilities; image magick does, I think. You'd need to insert the missing mimetype, and checks for the conversion into include/functions_images.inc.php, if you would really need to do it.

I still advise you shouldn't. :-)

Regards,
Garvin

Posted: Tue Dec 20, 2005 7:20 am
by sweety
Thank you garvin,
I will check the code to see if it can be changed or else just leave it....