Solved

Converting PNG to GIF or JPG

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Simple PHP/mySQL Query 3 51
How do I fix this error:  Warning: strpos(): Empty needle on line 122 3 16
MySQL Grouping 2 23
get domain with php 7 20
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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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

15 Experts available now in Live!

Get 1:1 Help Now