Starting with the original image - how are you loading that into your PHP script?
e.g. if a BMP is uploaded, are you using imagecreatefromwbmp()? This may matter a great deal - difficult to create a jpeg from a BMP, which may cause the library to default to the original image format - BMP - and output in that same format. This is just a theory however...
Main point to to create from the original format - do your resizing, etc. and create to the new format you need.
The simplest of examples from php manual:
Code: Select all
<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;
// Content type
header('Content-type: image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreate($newwidth, $newheight);
// need to set this to imagecreatefromXXX, where X is the original image
// format - grabbing the file extension and using this as the basis for a
// switch statement springs to mind
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb);
?>
Presumably you're saving the thumbnails - so remove the content-type, and set imagejpeg() to save to a file.