在Mediawiki中上传后调整图像大小 [英] Resize images upon upload in Mediawiki

查看:360
本文介绍了在Mediawiki中上传后调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将所有上传到MediaWiki的图像上调整大小并设置maxWidth和maxHeight之后,我是理想的选择.

I am ideally after resizing and setting a maxWidth and maxHeight on all my image uploads to mediawiki.

在MediaWiki中浏览了不同页面的文档,但是我找不到任何可以说您都可以编辑的图片,无论上传到基于mediaWiki的网站上的图像

Having looked through the documentation of various different pages in mediawiki I am unable to find anything that says you can edit in anyway images uploaded to a site built on mediaWiki

我编写一些自定义PHP没问题,但事实是我不知道从哪里开始在mediaWiki中查找.

I have no problem in writing some custom PHP but truth is I have no idea where to start looking in mediaWiki.

我的想法是:imagemagick与类似:

My thoughts are: imagemagick similarly to this:

I think you need the > flag on the resize:

convert -size 300x200 xc:red   small.png
convert -size 1000x500 xc:blue large.png
Now convert them both to 800x600 with no flags:

convert small.png -resize 800x600 a.png   # 800x533
convert large.png -resize 800x600 b.png   # 800x400
Now with flags:

convert small.png -resize 800x600\> a.png # 300x200
convert large.png -resize 800x600\> b.png # 800x400

但是同样,我看不到在上传图像后更改文件尺寸后在哪里运行.

But again, I cannot see where you would run this after an image upload to change the files dimensions.

任何帮助都是很棒的.

推荐答案

您可以尝试使用正确钩住的扩展名: https://www.mediawiki.org/wiki/Manual:Hooks/UploadForm:处理之前 或者 https://www.mediawiki.org/wiki/Manual:Hooks/UploadVerifyFile

You can try with an extension properly hooked : https://www.mediawiki.org/wiki/Manual:Hooks/UploadForm:BeforeProcessing or https://www.mediawiki.org/wiki/Manual:Hooks/UploadVerifyFile

此示例放在LocalSettings.php的末尾,在已上传文件的右上角添加徽标:

this example to put at the end of LocalSettings.php add a logo in the upper right corner of uploaded files :

$wgHooks['UploadForm:BeforeProcessing'][]=function(&$upload) { 
    $fictmp = $upload->mUpload->getTempPath();
    $newtmp = tempnam("/tmp", "tmp");
    $mylogo = "/path/to/my/logo/220px-SNice.svg.png";
    exec("composite -gravity NorthEast $mylogo $fictmp $newtmp" );
    copy($newtmp, $fictmp);
    unlink($newtmp);
    return true;
};

这篇关于在Mediawiki中上传后调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆