Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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):

imagefx_register_filter('custom-name','my_custom_filter');

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

}

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
add comment

Your Answer

 
discard

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.