mPDF将方形图像变成圆形

jjy*_*jyj 4 html css php mpdf

在mPDF中是否可以将图像做成圆圈?环顾四周,找不到明确的答案。

对我来说,这个图像显示得很好,除了它是一个正方形而且应该使它变成一个圆形。

的CSS

img{
    width: 150px;
    height: 150px;
    border-radius: 150px;
}
Run Code Online (Sandbox Code Playgroud)

的PHP

$inputPath = '../web_content/cool_cat.jpg';
<div class="profile_img">
    <img src="'.$inputPath.'"/>
</div>
Run Code Online (Sandbox Code Playgroud)

jjy*_*jyj 5

通过使用图像作为背景图像而不是元素,找到了一种解决此问题的方法。

因此,在使用mpdf创建pdf的PHP文件中,我刚刚做了一个div,可以将图像路径作为$ inputPath。似乎现在工作正常。

HTML / PHP

<div class="profile_img" style="background-image: url('.$inputPath.');"></div>
Run Code Online (Sandbox Code Playgroud)

的CSS

.profile_img {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 120px;
    border-style: solid;
    border-color: white;
    border-width: medium;

    overflow: hidden;

    background-size: 150px 150px;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center; 
 }
Run Code Online (Sandbox Code Playgroud)