用于Instagram的ffmpeg缩放图像(640x640)

时间:2017-09-13 13:54:44

标签: image ffmpeg

我正在尝试使用原始大小宽度缩放图像:634px和高度:845px到640x640用于Instagram上传。

试试这个

public static IHtmlString RenderSectionCustom(this HtmlHelper html)
{
    WebViewPage page = html.ViewDataContainer as WebViewPage;
    var section = page.RenderSection("CustomTop", false);
    return section == null ? MvcHtmlString.Empty : MvcHtmlString.Create(section.ToHtmlString());
}

public static IHtmlString DefineSectionCustom(this HtmlHelper html)
{
    WebViewPage page = html.ViewDataContainer as WebViewPage;

    page.DefineSection("CustomTop", () =>
    {
        page.Write(MvcHtmlString.Create(" hello world (custom top section from HTML HELPER)!"));
    });

    return MvcHtmlString.Empty;
}

但我得到宽度:480px和高度:640px。如何添加一些白色侧边栏以将图像恢复到640x640?

1 个答案:

答案 0 :(得分:0)

添加pad filter

ffmpeg -i input.jpg -vf "scale=w=640:h=640:force_original_aspect_ratio=decrease,pad=w=640:h=640:x=(iw-ow)/2:y=(ih-oh/2):color=white" output.png