0
votes

Hi,

I have a transparent png format image.But SAP system does not support PNG format.So I want to convert it to either GIF or JPEG. I tried to convert it using Adobe Photoshop and some other tools but the resulted image loses its transparency. Can any body please tell me solution ??? Here is my image

4
This does not seem to be programming related.Thomas Weller

4 Answers

1
votes

yes you can convert png to either GIF or JPEG without losing transparency....... this is done though the help of php lang...

<?php
$src = imagecreatefrompng("original_image.png");
$newImg = imagecreatetruecolor($nWidth, $nHeight);
 imagealphablending($newImg, false);
 imagesavealpha($newImg,true);
 $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
 imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
 imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight,
                      $imgInfo[0], $imgInfo[1]);

imagejpeg($newImg,"jpec_test_1.JPG",100);


imagedestroy($src);
imagedestroy($newImg);

?>
0
votes

You can't convert to JPEG as it does not support transparency. You should be able to conver to a GIF, just make sure to check the box next to transparency. However, the image you linked to actually does not appear to have transparency. Luckily, the image is a very simple gradient and you can easily reproduce this in Photoshop and then save it out as a GIF w/ transparency.

0
votes

Even if I didn't quickly succeed to accomplish that with the Gimp, I've found a site which suits your needs. It is a online tool: you haven't to download anything, just upload your png image and then download the generated gif. Try it:

http://images.my-addr.com/converter_png_to_gif_online_freeware_tool.php

Hope it helps.

0
votes

As noted by @Valjas, you JPEG doesn't support transparency. If you are converting just for reducing file size as JPEG has better compression, you might want to use https://tinypng.com/. It also has an API. I just used it for reducing file size of few PNGs.

BTW, I found this information while I was chasing the same problem ;)