Help - Search - Member List - Calendar
Full Version: BMP image upload works perfect but...
Krazy Letter Forums > Members stuff > Computer Programs > PHPKImageHost > Help!
sum
to get bmp files to upload i made some changes and got this:

CODE
switch($userfile_type)
{
case 'image/gif':
 break;
case 'image/png':
 break;
case 'image/jpeg':
 break;
case 'image/bmp':
 break;
default:
 echo "Problem: File is not a supported image filetype. Please upload a JPEG, PNG, or a GIF. Thanks. ";
 echo "<br> your file has a MIME-TYPE of $userfile_type";
 exit;
 break;
}


and


CODE
// Resample
$image_p = imagecreatetruecolor($width, $height);
if($userfile_type == 'image/jpeg')
{
$image = imagecreatefromjpeg($filename);
}
if($userfile_type == 'image/png')
{
$image = imagecreatefrompng($filename);
}
if($userfile_type == 'image/bmp')
{
$image = imagecreatefrompng($filename);
}
if($userfile_type == 'image/gif')
{
$image = imagecreatefromgif($filename);
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

// Output
if($userfile_type == 'image/jpeg')
{
imagejpeg($image_p, $thumb);
}
if($userfile_type == 'image/bmp')
{
imagepng($image_p, $thumb);
$userfile_type = 'image/png';
}
if($userfile_type == 'image/png' or $userfile_type == 'image/gif')
{
imagepng($image_p, $thumb);
$userfile_type = 'image/png';
}


now in the 2nd piece of code, there are errors which i dont know how to fix.

i get these errors when i upload a bmp image btw:

[QUOTE]Warning: imagecreatefrompng(): './uploads/110' is not a valid PNG file in /home/sumario/public_html/process.php on line 193[/QUOTE]

if($userfile_type == 'image/bmp')
{
$image = imagecreatefrompng($filename); <-----line 193
}

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/sumario/public_html/process.php on line 199[/QUOTE]


imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); <-----line 199



now even tho i get these errors, a bmp file will still be uploaded and saved on to the server/folders/database. but i dont get the thumbnali, its just a black box.

user posted image


line 193 is def wrong, thats for a png file not bmp. But, i cant find one for a bmp file:

imagecreatefrombmp <---that doesnt exist
imagecreatefromwbmp <----- that is completely wrong and get the error again.

so what is the right code for like 193?


line 199? i have no clue why it says its not an invalid arguement. is it because i get an error on like 193?

Hope that made sense and that you lot can help me out.

Thankyou.
Mynck
I found this thing that you might be able to use to convert bmp files. http://netpbm.sourceforge.net/
sum
seems a bit 2 advance for me but just in case, i will read a bit more into it. thanks.
Mynck
I found two other ways in case that one doesn't work.

Create a blank png image and use imagesetpixel() in a loop, setting each pixel of the png image to the value of the bmp pixel. This is resource-consuming, though.

Create a Flash application that converts BMP to some other image format, as described here: http://www.quasimondo.com/archives/000572.php
As long as you don't mind learning how to program in Flash.
sum
always wanted to learn to use flash, thanks smile.gif
Duckie
In your code I noticed it says for the bmp "createfrompng" that could be the problem, though not being a php programmer, I'm not sure if it has a createfrombmp function.
sum
QUOTE(Duckie @ Aug 10 2006, 04:11 PM)
In your code I noticed it says for the bmp "createfrompng" that could be the problem, though not being a php programmer, I'm not sure if it has a createfrombmp function.
*




i think u missed this part in my 1st post tongue.gif

QUOTE
line 193 is def wrong, thats for a png file not bmp. But, i cant find one for a bmp file:

imagecreatefrombmp <---that doesnt exist
imagecreatefromwbmp <----- that is completely wrong and get the error again.

so what is the right code for like 193?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.