PhaZZed Posted August 13, 2007 Share Posted August 13, 2007 Hi all, I have spent the last age trying to create a simple image conversion class, and have just not been able to get anywhere. I am limited to using the PHP GD Library unfortunately, so image magick is not an option. I have managed to convert from: .jpg to .gif and .png But I need to convert from: .jpg to .bmp and .tiff I tried this code: $image = @imagecreatefromjpeg($filename); if ($image === false) { die ('Unable to open image'); } $height = imagesy($image); $width = imagesx($image); $bmpdest = "../bmp/" . $rand . ".bmp"; $bmp = jpeg2wbmp($filename, $bmpdest, 100, 100, 4); But the .bmp is shown as invalid when I try open with an application. If anyone has any information or, well, absolutely anything that can help, it would be greatly appreciated if you would share your knowledge. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/ Share on other sites More sharing options...
AndyB Posted August 13, 2007 Share Posted August 13, 2007 .bmp is a special Windows format. You can't "convert" to a .bmp. The GD package includes a wbmp format but that's a special wireless image format not bmp Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322288 Share on other sites More sharing options...
PhaZZed Posted August 13, 2007 Author Share Posted August 13, 2007 I realized that it's for WAP basically. So, there isn't a way to convert to bmp then I take it Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322289 Share on other sites More sharing options...
gurroa Posted August 13, 2007 Share Posted August 13, 2007 Try it with http://phpthumb.sourceforge.net/. Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322293 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 won't do TIFF and it does say BMP but its using the GD library so i think thats only WBMP Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322296 Share on other sites More sharing options...
PhaZZed Posted August 13, 2007 Author Share Posted August 13, 2007 Madtechie, ye Wbmp is the conversion, which is mono graphic for WAP purposes, argh this is so annoying! Phpthumb.. someone else mentioned that, but I have not looked into it yet, seems like a way over kill for something like this.. Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322298 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 what about jpeg2wbmp if you are after WBMP.. if not then i think i found one awhile ago (will search my computer) Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322305 Share on other sites More sharing options...
gurroa Posted August 13, 2007 Share Posted August 13, 2007 won't do TIFF and it does say BMP but its using the GD library so i think thats only WBMP See http://phpthumb.sourceforge.net/index.php?source=phpthumb.bmp.php. Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322306 Share on other sites More sharing options...
PhaZZed Posted August 13, 2007 Author Share Posted August 13, 2007 WBMP is not what I am after. @gurroa - Ok, this is a little over my head, how would I pass a .jpg file to a function of that class? Sorry to be an annoyance, I'm just swimming in the deep end at the moment! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322319 Share on other sites More sharing options...
gurroa Posted August 13, 2007 Share Posted August 13, 2007 include('phpthumb.functions.php'); include('phpthumb.bmp.php'); $jpg = imagecreatefromjpeg('test.jpg'); $phpbmp = new phpthumb_bmp(); file_put_contents('test.bmp', $phpbmp->GD2BMPstring($jpg)); Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322337 Share on other sites More sharing options...
PhaZZed Posted August 13, 2007 Author Share Posted August 13, 2007 @gurroa - that's really kind of you! Seems to be working just fine, finally some progress! Now to try and tackle the jpg to tiff conversion, which I feel is going to be even worse! Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322347 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 maybe http://www.imagemagick.org/script/index.php Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322358 Share on other sites More sharing options...
PhaZZed Posted August 13, 2007 Author Share Posted August 13, 2007 include('phpthumb.functions.php'); include('phpthumb.bmp.php'); $jpg = imagecreatefromjpeg('test.jpg'); $phpbmp = new phpthumb_bmp(); file_put_contents('test.bmp', $phpbmp->GD2BMPstring($jpg)); Absolutely perfect, managed to edit a couple things so I could still pass another header() function, so things are working now! .tiff formatting, and then I can finally move onto a new module of this project, what a good feeling! thanks thanks thanks Quote Link to comment https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/#findComment-322363 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.