Dropzone.JS CreateImage缩略图 [英] Dropzone.JS CreateImage Thumbnails

查看:81
本文介绍了Dropzone.JS CreateImage缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我注意到DropzoneJS具有以下配置选项:createImageThumbnails( http://www.dropzonejs.com/#config-createImageThumbnails ).

So I noticed that DropzoneJS has the following Configuration Option being: createImageThumbnails (http://www.dropzonejs.com/#config-createImageThumbnails).

但是我没有找到任何有关如何使用此配置选项以及如何使用此选项将缩略图保存在服务器上的适当信息.

But I didn't find any proper information to how this configuration option can be used, and how I can save thumbnails on my server by using this option.

我目前正在使用Laravel 5.3通过DropzoneJS进行整个上传,因此我想进行一些缩略图控制,所以我的问题是.这将是通过DropzoneJS进行操作的好方法,如果可以的话,怎么做?还是用PHP明智?

I'm currently using Laravel 5.3 to do the whole uploading via DropzoneJS so I would like to have some thumbnail control, so my question here is. Would it be a good way to do it via DropzoneJS and if so how? OR do it php wise?

感谢提前提供更多信息.

Thanks for further information in advance.

推荐答案

我不建议使用实现 createImageThumbnails() createThumbnailFromUrl()方法.

I would not recommend using the createThumbnailFromUrl() method which implements createImageThumbnails().

原因是-每次执行此操作时,都会强制用户在客户端上创建缩略图(CPU/Mem资源密集型).然后,他们必须将图像发送到服务器(网络/带宽密集型).

The reason being is that - each time you do this, you'll force the user to create the thumbnail on the client side (CPU/Mem resource intensive). Then, they'll have to send the image to the server (Network/Bandwidth intensive).

相反,我建议仅在服务器上创建缩略图.您可以按比例缩小客户端(原始)上的图像,以最小的资源成本(零网络/带宽成本)进行查看.

Instead, I would recommend just creating the thumbnails on the server. You can scale down the images on the client side (the original) for viewing with minimal resource cost (zero network/bandwidth cost).

然后服务器可以处理缩略图的创建.为此,您可以使用诸如干预库的fit()命令之类的方法.这是一个使用回调的示例,以确保在任一维度中调用-> upsize()时,图像都不会比原始图像大.

The server can then handle the thumbnail creation. You can use something such as the Intervention library's fit() command for this. Here's an example using a callback to ensure that the image does not get made any larger than the original in either dimension calling ->upsize().

$img = Image::make('/path/to/my/img.ext');
$img->fit(120, 72, function ($constraint) {
    $constraint->upsize();
});

希望这对您有帮助,而且很有帮助.

Hope this was informative and helpful.

这篇关于Dropzone.JS CreateImage缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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