2

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.

  • 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
4

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: https://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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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