Viewing 3 replies - 1 through 3 (of 3 total)
  • hey, the User Photo plugin doesn’t handle transparency. If you want you can modify the code a little.

    here is what you need to do(User Photo ver. 0.9.5.1)
    code taken from: http://wordpress.org/support/topic/plugin-user-photo-transparent-png-support?replies=4

    1. open “user-photo.php”
    2. find line 899

      elseif ( $info[2] == IMAGETYPE_PNG ) {
      			if (!imagepng( $imageresized, $newFilename ) ) {
      				$error = __( "Thumbnail path invalid" );
      			}
      		}
    3. change it to
      elseif ( $info[2] == IMAGETYPE_PNG ) {
                      	@ imageantialias($imageresized,true);
          			@ imagealphablending($imageresized, false);
          			@ imagesavealpha($imageresized,true);
          			$transparent = imagecolorallocatealpha($imageresized, 255, 255, 255, 0);
          			for($x=0;$x<$image_new_width;$x++) {
          				for($y=0;$y<$image_new_height;$y++) {
          					@ imagesetpixel( $imageresized, $x, $y, $transparent );
         			 		}
          			}
          			@ imagecopyresampled( $imageresized, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $info[0], $info[1] );
         			if (!imagepng( $imageresized, $newFilename ) ) {
      				$error = __( "Thumbnail path invalid" );
      			}
      		}
    4. Upload your photo again
    Thread Starter casperreiff

    (@casperreiff)

    Thanks a lot, but it doesn’t really work.
    Now it doesn’t upload the photo at all.

    I’ll just tell the client to make sure the image has a white background.

    Do you know if it supports transparent GIF from standard?

    Thx. This code worked perfectly for me.
    I can upload PNG’s whith transparent background.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: User Photo] Transparent Background’ is closed to new replies.