Jump to content

[SOLVED] PHP Image Conversion Help..


PhaZZed

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/64646-solved-php-image-conversion-help/
Share on other sites

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

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.