Page 1 of 1

Convert image types

Posted: Thu Oct 09, 2003 2:57 pm
by Zamees
How do I go about converting .bmp and .GIF to .jpg

What kinda PHP tricks can i do?

Posted: Thu Oct 09, 2003 3:24 pm
by mrvanjohnson
Can you give us an example of how you would use this? Why would you want PHP to do this? Wouldn't be easier to just upload the image in whatever format you want?

You could always just have PHP change the extension but this wouldn't be really "converting" it.

Posted: Thu Oct 09, 2003 3:56 pm
by Gen-ik
You could probably use GD to do this but I'm not sure if it can use BMP files. It can use WBMP files but I'm not sure if that's the same or not.

Anyway here's an example.......

Code: Select all

<?php
$im = imagecreatefromgif($theImage);
imagejpeg($im, "images/converted.jpeg", 100);
?>
......might be worth checking out GD if your not sure how to use it.

Posted: Thu Oct 09, 2003 4:04 pm
by xisle
this app could work also...

http://www.imagemagick.org/

here's an example system command on a Linux server, the app is very powerful for image manipulation.

this converts pdf to jpg and to 150 dpi.

Code: Select all

<?php
system("convert -density 150x150 pdf:$source jpg:$destination");
?>

Posted: Thu Oct 09, 2003 5:41 pm
by Zamees
The server I run on has imagemagik, so ill give that a try. The whole thing to this is that users upload their picture, and if its a bmp or a gif then i can't throw it into my resize script, so i'll need to convert first. Im fairly new to php, my site is written in ASP, with one php script hopefully, this works out well.

Posted: Thu Oct 09, 2003 5:45 pm
by Zamees
just outta curiousity, how do i go about running a system command on my page. Do I just type that code in like it is. So i'd do a

If fileextension = .pdf,

php code above

end if

Posted: Fri Oct 10, 2003 12:41 am
by evilMind
A good place to start is http://us2.php.net/manual/en/ref.image.php. Make sure to look at the imagecreatefrom* functions as that is the first function you should use to convert an image.