Removing black bars off video thumbnail

筅森魡賤 提交于 2019-12-05 21:34:34

If you want to go by the color, the wideimage library (GD based) has this implemented already. The method is called autoCrop, an online demonstration exists.

This might already fulfil your needs.

One of the solutions is to do same thing which youtube did. If you visit their site, and look at the image and element that wraps image, you will see that wrap element have css similar to this one:

display:inline-block;
height: /*here goes fixed height in px*/
overflow: hidden;

They are using image which contain black areas on top and bottom (within that container), but they used css to hide it. This means that element (on youtube span with att display:inline-block) will be smaller then acctual picture, and picture will be centered/positioned like that so top and bottom black areas will overflow smaller wrap and will be hidden.

You should check the video's ratio (4:3 or 16:9) and crop the thumbnail to keep that ratio. Not trying to detect the color.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!