0

There are images displayed inside a HTML table in a PHP code :

enter image description here

The code of this table is :

for ($i = 0; $i < $data['list']['cnt']; $i++) {             
    $tabRows[$i][1]['width']    = "45%";
    $tabRows[$i][1]['align']    = "center";
    $tabRows[$i][1]['value']    = '<img src="'.HTTP_FIGURES.$data['list'][$i]['fig_image'].'" />';
}

As you can see the background of the images are seen and they make the page dirty. So I want to remove the background of each image. How to do that ?

pheromix
  • 18,213
  • 29
  • 88
  • 158
  • Those images - are they uploaded by user or it is just a predefined set of pics? – Viktor S. Sep 18 '12 at 09:29
  • @Prisoner : yes , make the images transparent. – pheromix Sep 18 '12 at 09:31
  • @FAngel : images are in directory. – pheromix Sep 18 '12 at 09:31
  • If the white background is part of the image file, the only way I can think of is using Canvas and Javascript: http://stackoverflow.com/questions/11472273/how-to-edit-pixels-and-remove-white-background-in-a-canvas-image-in-html5-and-ja. AFAIK you can't edit the images through front-end code, you'll need to take them into an image editor and remove the white background manually – MassivePenguin Sep 18 '12 at 09:35
  • Edit your image with your favorite image editor, and make their background transparent (save as PNG, because JPG does not handle transparancy/alpha). – AliSoftware Sep 18 '12 at 09:43

4 Answers4

0

Make the images a transparent PNG.

Martin Bean
  • 38,379
  • 25
  • 128
  • 201
0

Your only practical solution is to go through each image with an image editor, delete the background and re-save as a .png with transparency.

Dunhamzzz
  • 14,682
  • 4
  • 50
  • 74
0

Take any image editor like GIMP (free), Paint.net(free), Photoshop or any other image editor and add transparency where you need it. Here is a tutorial for paint.net. If your images are not in PNG - you will need to make PNG images as JPEG has no transparency.

Viktor S.
  • 12,736
  • 1
  • 27
  • 52
0

You have 2 options:

  1. Edit images with a image editor like paint.net and make the backgrounds transparent.
  2. Use the PHP GD functions to 'edit' the images. This can be cumbersome, because you have to determine what color you want to replace with a background color. Often, a fixed color is used, or the color in pixel[1,1].

My advise, if there are not to many images, go for 1.

JvdBerg
  • 21,777
  • 8
  • 38
  • 55