Jump to content

ploblem with resize


yosii

Recommended Posts

look'i have a code that to a resize to picture

 

function makeimage($filename, $newfilename, $path, $newwidth, $newheight) {

 

    //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER . )

    $image_type = strstr($filename,  '.');

 

    //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION

        switch($image_type) {

            case '.jpg':

                $source = imagecreatefromjpeg($filename);

                break;

            case '.png':

                $source = imagecreatefrompng($filename);

                break;

            case '.gif':

                $source = imagecreatefromgif($filename);

                break;

 

            default:       

                return;

            }

   

    //CREATES THE NAME OF THE SAVED FILE

    $file = $newfilename . $filename;

   

    //CREATES THE PATH TO THE SAVED FILE

    $fullpath = $path . $file;

 

    //FINDS SIZE OF THE OLD FILE

    list($width,  $height) = getimagesize($filename);

 

    //CREATES IMAGE WITH NEW SIZES

    $thumb = imagecreatetruecolor($newwidth,  $newheight);

 

    //RESIZES OLD IMAGE TO NEW SIZES

    imagecopyresized($thumb,  $source,  0,  0,  0,  0,  $newwidth,  $newheight,  $width,  $height);

    unlink($filename);

    //SAVES IMAGE AND SETS QUALITY || NUMERICAL VALUE = QUALITY ON SCALE OF 1-100

    imagejpeg($thumb,  $fullpath,  60);

 

    //CREATING FILENAME TO WRITE TO DATABSE

    $filepath = $fullpath;

   

 

    }

 

it's work but if i try to resize "bmp" image that function return eror

i treid to add

          case '.gif':

                $source = imagecreatefromwbmp($filename);

                break;

 

but that do 2 error

imagecreatefromwbmp() [function.imagecreatefromwbmp]: 'pic/3.bmp' is not a valid WBMP file in

 

imagecopyresized(): supplied argument is not a valid Image resource

 

help me please to resize bmp image

thank

 

 

Link to comment
https://forums.phpfreaks.com/topic/121548-ploblem-with-resize/
Share on other sites

WBMP is a Wireless BMP file with the ".wbmp" extension. PHP doesn't currently support native BMP files. I guess ImageMagick supports BMP but you'll have to rewrite the entire script (or probably find another one :)). Don't know what are you using that code for, but usually jpgs or pngs are preferred image formats, so just support them.

Link to comment
https://forums.phpfreaks.com/topic/121548-ploblem-with-resize/#findComment-626864
Share on other sites

WBMP is a Wireless BMP file with the ".wbmp" extension. PHP doesn't currently support native BMP files. I guess ImageMagick supports BMP but you'll have to rewrite the entire script (or probably find another one :)). Don't know what are you using that code for, but usually jpgs or pngs are preferred image formats, so just support them.

according that script i support jpg and png,rghit??

so...you don't have any idea for me how to do resize to bmp????

Link to comment
https://forums.phpfreaks.com/topic/121548-ploblem-with-resize/#findComment-626894
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.