Solved

Converting PNG to GIF or JPG

Posted on 2004-09-03
3
4,369 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now