gpt4 book ai didi

youtube - 如何从youtube预览图像中删除黑色边框(图像黑色边框的长度不同)

转载 作者:行者123 更新时间:2023-12-03 06:05:51 27 4
gpt4 key购买 nike

我已经通过以下链接
-> Removing black borders 4:3 on youtube thumbnails
-> How to remove black border of Youtube image
-> https://stackoverflow.com/questions/13220715/removing-black-borders-43-on-youtube-thumbnails#:~:text=To%20remove%20the%20black%20borders,which%20come%20from%20that%20domain
我们的项目中有很多不同大小(宽度和高度)的视频。
尝试以下解决方案
解决方案1 ​​:裁剪或调整高度

         HTML
<div class="thumb">
<img src="...">
</div>

CSS

.thumb {
overflow: hidden;
}
.thumb img {
margin: -10% 0;
width: 100%;
}

Failing for some sceanrios , because of image black border size is varying for few images.

Screenshot for reference
Image with less black border
Image with more black border
解决方案2 :将其用作背景图像,将其居中并更改高度。
    .youtubePreview {
background:url('http://img.youtube.com/vi/aOPGepdbfpo/0.jpg') center no-repeat;
height:204px;
width:480px;
}

or

also tried with background-image

<div class="bgimg" style="background-image: url(&quot;https://img.youtube.com/vi/8yxZ-k0xI9s/0.jpg&quot;); height:275px "></div>

Example: 450*275 failing

We have video with different sizes so it works for some width and its failing for other widths.
解决方案3:获取没有黑色边框的Youtube图像(使用mqdefault.jpg而不是0.jpg)
跟着这个链接 How do I get a YouTube video thumbnail from the YouTube API?
根据以上链接,我们知道mqdefault.jpg图像没有黑色边框
   We using url for images https://img.youtube.com/vi/YOUTUBEVIDEOID/0.jpg 

so replaced with https://img.youtube.com/vi/YOUTUBEVIDEOID/mqdefault.jpg


But unfortunately few mqdefault images having black borders at left and right side.''
mqdefault image
  • 许多大小(高度和宽度)不同的视频
  • 预览图像的黑色边框长度也有所不同

  • 任何人都可以提出一些想法来实现这一目标吗?
    提前致谢

    最佳答案

    这是我改编的一些示例(通过检查嵌入视频并查看其CSS样式):
    范例1:

    .ytp-cued-thumbnail-overlay-image {
    background-size: cover;
    -moz-background-size: cover;
    -webkit-background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: absolute;
    }
    <p>Image 1: </p>
    <div class="ytp-cued-thumbnail-overlay-image" style="background-image: url('https://i.ytimg.com/vi/3TJgmUGFHqw/sddefault.jpg');"></div>

    范例#2:

    .ytp-cued-thumbnail-overlay-image {
    background-size: cover;
    -moz-background-size: cover;
    -webkit-background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: absolute;
    }
    <p>Image 2: </p>
    <div class="ytp-cued-thumbnail-overlay-image" style="background-image: url('https://i.ytimg.com/vi/NNgYId7b4j0/maxresdefault.jpg');"></div>

    关于youtube - 如何从youtube预览图像中删除黑色边框(图像黑色边框的长度不同),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63807811/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com