When I upload a transparent PNG the background turns either white or black on the resized images
When I upload a transparent PNG the background turns either white or black on the resized images
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
elseif ( $info[2] == IMAGETYPE_PNG ) {
if (!imagepng( $imageresized, $newFilename ) ) {
$error = __( "Thumbnail path invalid" );
}
}
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" );
}
}
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?
You must log in to post.