Re: MIME file and gd



Hi,

The best way to get the image type is exif_imagetype. If you don't
have that you can also use getimagesize.

Now, if you want a general way to convert between image types, the
easiest is to use the convert command that comes with ImageMagick.
Here's a function to convert many image types:

<?

function imConvert($path, $newPath)
{
$cmd = 'convert ' . escapeshellarg($path) . ' ' .
escapeshellarg($newPath) . ' 2>&1';
exec($cmd, $output, $exitCode);
if ($exitCode != 0) {
throw new Exception("Command \"$cmd\" failed with " .
"exit code $exitCode: " . join("\n", $output));
}
}

$path = dirname(__FILE__) . '/img.gif';
$newPath = dirname(__FILE__) . '/im.jpg';
imConvert($path, $newPath);

?>

You can also use GD to do this. To convert from GIF to JPEG, you would
call imagecreatefromgif then imagejpeg.

Regards,

John Peters

On Mar 28, 9:08 pm, amit <amit.ko...@xxxxxxxxx> wrote:
On Mar 28, 5:58 pm, amit <amit.ko...@xxxxxxxxx> wrote:



Hello group,

I'm uploading some image files such as jpeg, png and gif. However, I
must convert time to jpeg type. I have few questions:

1) Can I convert time in using gd library?

2) Currently, I check the MIME file to see what is holding (thanks to
Michael ) like image/jpg or image/gif or image/png. But what should be
the criteria? I'm checking:

if ($img_array_info[mime] == "image/jpg" {
...
}

However, there are some files that rather image/jpg they have image/
jpeg as mime in their headers. Should I compare it agaisnt these two
criteria or there are other things I have to consider too?

Thanks,
Amit

Currently I'm doing this:

if ( (strcasecmp($array_img_information[mime], "image/jpg") == 0 ) ||
(strcasecmp($array_img_information[mime], "image/jpeg") == 0 ) )
{
echo "<br>OK, jpeg file<br>";}

else
{
echo "<br>$array_img_information[mime]<br>";
echo "<br>Not a jpeg file must conver it!<br>";

}

Is this a proper way or ....?

Thanks again.

.



Relevant Pages

  • Re: AVI or WMV
    ... wide range of image types that are JPeg, Movie maker can only cope with ... JPeg images are specifically included in the open file dialog. ... how well Movie Maker copes with MP3's as well. ...
    (microsoft.public.windowsxp.moviemaker)
  • Re: Best Win32 Image Tool
    ... Our new pyro lib loads many different formats, with use of other 3rd party ... For jpeg we have our own library too, ... multiple image types. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: MIME file and gd
    ... Now, if you want a general way to convert between image types, the ... To convert from GIF to JPEG, ... Michael) like image/jpg or image/gif or image/png. ... criteria or there are other things I have to consider too? ...
    (comp.lang.php)
  • Re: MIME file and gd
    ... I'm uploading some image files such as jpeg, ... I check the MIME file to see what is holding (thanks to ... Michael) like image/jpg or image/gif or image/png. ... criteria or there are other things I have to consider too? ...
    (comp.lang.php)
  • MIME file and gd
    ... I'm uploading some image files such as jpeg, ... I check the MIME file to see what is holding (thanks to ... Michael) like image/jpg or image/gif or image/png. ... criteria or there are other things I have to consider too? ...
    (comp.lang.php)