[wordpress插件] Auto Smart Thumbnails自动智能缩略图

wordpress 插件 文章 2020-02-24 20:10 618 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

I.

I。

Face detection

人脸检测

WordPress (WP) plugin/themes crop images per fixed position (top, center, bottom x left, center, right).

WordPress(WP)插件/主题按固定位置(顶部,中心,底部x左,中心,右)裁剪图像。

This often generates thumbnails with faces being cut.

这通常会生成带有被剪切面的缩略图。

This plugin (Auto Smart Thumbnails, AST) employs face detection to keep the face.

该插件(自动智能缩略图,AST)采用人脸检测功能来保留人脸。

II.

II。

Downsize images

缩小图片

There are many ways to backup/store your images.

有许多方法可以备份/存储图像。

Your webhost server is the last place for that though.

您的Web主机服务器是最后一个。

Essentially, your web server serves one purpose and one purpose only: a fast website.

本质上,您的Web服务器仅用于一种目的和一种目的:快速的网站。

So making it small and agile is critical in both user experience and website maintenance.

因此,使其小巧而灵活对于用户体验和网站维护都至关重要。

Media files (pdf, movie and images) are usually the biggest space eaters.

媒体文件(pdf,电影和图像)通常是最大的占用空间的人。

Here are some practice tips related to images:

以下是一些与图像有关的练习技巧:

1. Use jpg to store images.

1.使用jpg存储图像。

No png except for the logo images.

除徽标图片外,没有png。

2. Downsize your images to about (1920×1080, full high definition, FHD).

2.将图像缩小到大约(1920×1080,全高清,FHD)。

3. Get rid of those unsed thumbnails.

3.删除那些未使用的缩略图。

AST does 2 and 3. It helped to trim my website from 24G to 9G.

AST做2和3。这有助于将我的网站从24G减少到9G。

AST downsizes big images in a smart way.

AST以一种智能的方式缩小了大图像的尺寸。

It does so by a factor of an integer, e.g.

这样做的系数是整数,例如

2, 3, 4 etc, so that the result image looks as sharp as the original in a webpage.

2、3、4等,以便结果图像看起来像网页中的原始图像一样清晰。

E.g.

例如。

an image of (5184×3456) is downsized by 3 to (1728×1152) and its file size is down from 4.9M to 239K.

(5184×3456)的图像缩小3到(1728×1152),其文件大小从4.9M减小到239K。

Conventional tools downsize it by 3.2 (=3456/1080) to (1687×1080, short side exact FHD).

常规工具将其尺寸缩小3.2(= 3456/1080)至(1687×1080,短边精确FHD)。

Blurring happens because of the pixels fractioned.

由于像素被分割而发生模糊。

For images smaller than 3840×2160, which can't even be downsized by a factor of 2, they will be compressed (at WP default quality of 82%. Though the document says the default quality is 90%, in code

对于小于3840×2160的图像,甚至无法将其缩小2倍,它们将被压缩(WP默认质量为82%。尽管文档说默认质量为90%,但在代码中

it's 82%.)

是82%。)

III.

III。

Cleanup thumbnails

清理缩略图

Some WP themes generate many, sometimes 10s of, custom sized thumbnails when an image is uploaded.

上载图像时,某些WP主题会生成许多(有时是数十个)自定义尺寸的缩略图。

These thumbnails may never be used yet take up your precious server storage space.

这些缩略图可能永远不会使用,但会占用您宝贵的服务器存储空间。

AST helps remove these unused thumbnails and stop them from being generated when an image is uploaded.

AST帮助删除这些未使用的缩略图,并阻止它们在上载图像时生成。

A thumbnail is generated only when it is requested.

缩略图仅在需要时才生成。

The newly generated thumbnail is then stored for later use.

然后将新生成的缩略图存储起来以供以后使用。

Notes

注释

AST is based on ‘Optimize Images Resizing’ by OriginalEXE.

AST基于OriginalEXE的“优化图像大小调整”。

Face detection algorithm is by Maurice Svay (php-facedetection by mauricesvay at github.com).

人脸检测算法是由Maurice Svay提供的(mauricesvay的php-facedetection在github.com上)。

It returns only the first face candidate detectd.

它仅返回检测到的第一个面部候选者。

It mostly does the job and and it’s a little faster then another implementation PHP-FaceDetector by Felix Koch.

它主要完成工作,并且比Felix Koch的另一个实现PHP-FaceDetector快一点。

When it fails to detect face(s), the cropping will done by the system.

如果无法检测到面部,系统将进行裁剪。

The module is designed with extensibility that other plugin can do face detection, e.g.

该模块具有可扩展性,其他插件可以进行面部检测,例如

faster or with more accuracy, and feeds the dection result with the meta data of an image.

更快或更准确,并向检测结果提供图像的元数据。

AST can pick up the data to do cropping.

AST可以拾取数据进行裁剪。

This is done by adding a new field ‘focal_area’ in the meta data, as below:

这是通过在元数据中添加新字段“ focal_area”来完成的,如下所示:

Array (    

  Array(    

[width] => 512    

[宽度] => 512    

[height] => 512    

[高度] => 512    

[file] => 2019/04/sample-image-file.jpg    

[文件] => 2019/04 / sample-image-file.jpg    

[sizes] => Array ()    

[sizes] => Array()    

[focal_area] = (        

[focal_area] =(        

[x] => 100        

[x] => 100        

[y] => 123        

[y] => 123        

[w] => 58        

[w] => 58        

[h] => 58        

[h] => 58        

[faces] => Array (            

[faces] => Array(            

[tharavaad-svay] => Array (                

[tharavaad-svay] =>数组(                

[0] => Array (                    

[0] =>数组(                    

[x] => 100                    

[x] => 100                    

[y] => 123                    

[y] => 123                    

[w] => 58                

[w] => 58                

)            

)            

)            

)            

[koch] => Array (                

[koch] =>数组(                

[0] => Array (                    

[0] =>数组(                    

[x] => 100                    

[x] => 100                    

[y] => 123                    

[y] => 123                    

[w] => 58                

[w] => 58                

)                

)                

[1] => Array (                    

[1] =>数组(                    

...                

...                

)            

)            

)        

)        

)    

)    

)

)

The focal_area is defined by the position (x,y) and width and height.

focus_area由位置(x,y)以及宽度和高度定义。

External plugin can store the detection result with these 4 parameters.

外部插件可以使用这四个参数存储检测结果。

AST can pick them up for cropping.

AST可以将它们捡起来进行裁剪。

The ‘focal_area’ can be non-face objects that users want to focus on.

“焦点区域”可以是用户要关注的非面部对象。

Within it, the optional ‘faces’ array defines faces detected and the algorithm used.

在其中,可选的“面部”数组定义了检测到的面部和使用的算法。

To make it simple, some assumption and number decisions below:

为简单起见,下面是一些假设和数字的决定:

    1. To resave png images in jpg will save a lot space.

      在jpg中重新保存png图像将节省大量空间。

      But it needs to mess up with the WP database, which I stayed away.

      但是它需要弄乱我一直不在的WP数据库。

    2. An image is downsized only when its short side > 2×1080.

      仅当短边> 2×1080时,才缩小图像尺寸。

      Otherwise it’s re-compressed when its size >128k bytes.

      否则,当其大小> 128k字节时,将重新压缩。

      The new jpg file replaces the original only when it’s 25k bytes smaller.

      新的jpg文件只有在缩小25k字节时才会替换原始文件。

    3. When a downsizing happens, the original is saved in uploads/ast-backup.

      缩小时,原始文件将保存在上载/ ast备份中。

      The year/month structure is preserved.

      保留年/月结构。

      To save the server storage space, it’s recommended to ftp download it and delete it from the server.

      为了节省服务器存储空间,建议通过ftp下载并将其从服务器中删除。

    I didn’t get time to handle the localization language files yet.

    我还没有时间处理本地化语言文件。

    Please let me know how it works for you, or any improvement suggestions or feedback.

    请让我知道它如何为您工作,或者有任何改进建议或反馈。

    Thanks!

    谢谢!

安装步骤

In WP ‘Add Plugins’, seach for ‘auto-smart-thumbnails’ and ‘Install Now’, and activate it.

在WP“添加插件”中,搜索“自动智能缩略图”和“立即安装”,然后将其激活。

下载地址
https://downloads.wordpress.org/plugin/auto-smart-thumbnails.1.1.0.zip
-EOF-

AI助手支持GPT4.0