我正在尝试使用HTML,CSS和JavaScript制作网站代码,以便有人上传图片,并且:
到目前为止,我已经能够从this个答案之一中提出Martin Zikmund's关于如何添加个人资料图片的方法,该个人资料图片可以拍摄照片并将其裁剪成圆圈(它不会居中虽然现在可以通过打印页面来粗略地完成打印步骤,但是我不确定如何在边缘附近添加文本以及如果我可以允许用户仅打印出所述图片。
到目前为止我能够把所有这些归结为this answer
$("#profileImage").click(function(e) {
$("#imageUpload").click();
});
function fasterPreview( uploader ) {
if ( uploader.files && uploader.files[0] ){
$('#profileImage').attr('src',
window.URL.createObjectURL(uploader.files[0]) );
}
}
$("#imageUpload").change(function(){
fasterPreview( this );
});
#imageUpload
{
display: none;
}
#profileImage
{
cursor: pointer;
}
#profile-container {
width: 1.125in;
height: 1.125in;
overflow: hidden;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
border-radius: 50%;
}
#profile-container img {
width: 150px;
height: 150px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="profile-container">
<image id="profileImage" src="https://lorempixel.com/100/100" />
</div>
<input id="imageUpload" type="file"
name="profile_photo" placeholder="Photo" required="" capture>