Solved

Converting PNG to GIF or JPG

Posted on 2004-09-03
3
4,381 Views
Last Modified: 2010-10-05
Hi,

I have a series of PNG files and i want to convert these PNG files to GIF (or JPG) file formats. How can i do this with PHP?

Thanks in advance,
0
Comment
Question by:blacklord
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 125 total points
ID: 11970996
<?php

$imgname = 'mypic.png';
$im = @imagecreatefrompng($imgname);
header ("Content-type: image/jpeg");
$quality = 99; // Quality should be between 0 and 100
imagejpeg($im, '', $quality);

?>

http://www.php.net/imagejpeg
0
 
LVL 4

Expert Comment

by:chipple
ID: 11971011
By the way, recent version of GD (PHP's graphic library) don't support GIF.
0
 
LVL 33

Expert Comment

by:sajuks
ID: 11978509
Thanks for the points and grade
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question