Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.