on-internet
← Community

convert png to jpg and download jpg image

Stack Overflow ·

I have given an option to user to Export Images As JPG and I have stored png images So, i have created some php script to do so. png is converting fine.. but when i downloaded the jpg image and try to open in image viewer, its showing corrupted. My php code: Converting PNG to JPG $input_file = 'images/image1364926178.png'; $filename = time().'.jpg'; $output_file = 'images/'.$filename; $input = imagecreatefrompng($input_file); if($input){ list($width, $height) = getimagesize($input_file); $output = imagecreatetruecolor($width, $height); $white = imagecolorallocate($output, 255, 255, 255); image

Comments

Sign in or sign up to comment and upvote.

No comments yet.