gif 2 jpg conversion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
moeed
Forum Newbie
Posts: 6
Joined: Thu Aug 07, 2003 10:48 pm

gif 2 jpg conversion

Post by moeed »

Is it possible to convert gif image in to jpg image on the fly using GD library
Moeed
User avatar
Orkan
Forum Commoner
Posts: 32
Joined: Sun Aug 24, 2003 9:07 am
Location: Ukraine
Contact:

Yes! This is easy!

Post by Orkan »

Here is a code for doing this:

Code: Select all

<?php
$imgfile="asc.gif";
$image=imageCreateFromGIF($imgfile);
imageJpeg($image, "asc.jpg");
@imagedestroy($image);
?>
converts asc.gif in asc.jpg
moeed
Forum Newbie
Posts: 6
Joined: Thu Aug 07, 2003 10:48 pm

Post by moeed »

Thanx for the reply. I have used the code supplied by u but it produces an error whih is given below. Can u please figure out problem.

Code: Select all

Warning: ImageCreateFromGif: No GIF read support in this PHP build in c:\apache\htdocs\convert.php on line 3

Warning: Supplied argument is not a valid Image resource in c:\apache\htdocs\convert.php on line 4
Thank You
Moeed
User avatar
Orkan
Forum Commoner
Posts: 32
Joined: Sun Aug 24, 2003 9:07 am
Location: Ukraine
Contact:

:(

Post by Orkan »

What can I say... try installing new PHP version or GD library...
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

From PHP Manual -
"Versions of GD older than gd-1.6 support GIF format images, and do not support PNG, where versions greater than gd-1.6 support PNG, not GIF."

"GIF - Only supported in GD versions older than gd-1.6. Read-only GIF support is available with PHP 4.3.0 and the bundled GD-library."

You can check your PHP install details using:

<?php
phpinfo();
?>

and look for word/section - gd
User avatar
Orkan
Forum Commoner
Posts: 32
Joined: Sun Aug 24, 2003 9:07 am
Location: Ukraine
Contact:

Funny...

Post by Orkan »

Funny thing...

I have PHP v. 4.1.2. and GD2 and can read GIF, read&create PNG...

:\
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

Orkan: do you have both support - read & create - GIF with PHPv4.1.2/GD2.
User avatar
Orkan
Forum Commoner
Posts: 32
Joined: Sun Aug 24, 2003 9:07 am
Location: Ukraine
Contact:

Post by Orkan »

Only read GIF
But read and create PNG...
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

due to compuserve's new owners getting picky and wanting royalties youhave to get a third party add in to do more than read. read is still open to everyone. anything more and you now have to pay royalties.

therefore it was dropped in versions newer than 1.6
many hosts will get third party add ins so you can still do stuff though, so check with your host.
Post Reply