WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to convert automatically uploaded PNGs to JPEGs and keep the original? In other words, let the user upload a PNG, but show in wordpress (thumbnails, large, medium, etc) the JPEG version and only show the original uploaded PNG when Wordpress request the full image.

share|improve this question
I'm not aware of a way to do this easily, but more to the point I'm not sure WHY you would want to do this. PNG is a better file format, and if someone uploads an image with transparency it's guaranteed to look like crap when converted to a JPG. – SickHippie Jul 2 '12 at 19:35
up vote 4 down vote accepted

There is a way, I recommend you combine the imagefx plugin with a custom function , http://wordpress.org/extend/plugins/imagefx/

You can read about it here: http://ottopress.com/tag/gd/ , and use a function like one found here: http://stackoverflow.com/questions/1201798/use-php-to-convert-png-to-jpg-with-compression

It would look something like (not tested):


function my_custom_filter(&$image, $outputFile, $quality) {
$image = imagecreatefrompng(&$image);
imagejpeg($image, $outputFile, $quality);


But remember they are not the same format and .jpg does doesn't support alpha-transparency

share|improve this answer
Yes, that is what is was looking for. I will give it a shot. – DarkGhostHunter Jul 2 '12 at 20:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.