简体   繁体   English

使用Jcrop裁剪并上传大尺寸图片

[英]Crop & upload image of big size using Jcrop

I'm using Jcrop to crop and upload image. 我正在使用Jcrop裁剪和上传图像。 I'm using this tutorial and source code to develop my system 我正在使用本教程和源代码来开发系统

html5-image-uploader-with-jcrop html5-image-uploader-with-jcrop

Now it can't handle images that are more than 250 KB. 现在,它不能处理超过250 KB的图像。 It gives an error as 它给出了一个错误

You have selected too big file, please select a one smaller image file 您选择的文件太大,请选择一个较小的图像文件

So I tried to change the script.js . 所以我试图更改script.js On the fileSelectHandler method, I tried to change this line fileSelectHandler方法上,我尝试更改此行

if (oFile.size > 250* 1024) 如果(oFile.size> 250 * 1024)

with

if (oFile.size > 2048 * 2048) 如果(oFile.size> 2048 * 2048)

But it didn't work. 但这没有用。 I can't find any other option to change. 我找不到其他可更改的选项。 Can anyone please tell me what I'm missing? 谁能告诉我我想念的东西吗? How can I withdraw this size restrictions? 如何撤消此尺寸限制? I want to handle 2mb size image or at least of (1024*1024) pixels size image. 我想处理2mb大小的图像或至少(1024 * 1024)像素大小的图像。 Please help...... 请帮忙......

1st changed the upload.php file. 1日更改了upload.php文件。 A line from 一条线从

if (! $_FILES['image_file']['error'] && $_FILES['image_file']['size'] < 250 * 1024)

to

if (! $_FILES['image_file']['error'] && $_FILES['image_file']['size'] < 2048* 2048)

As I mentioned in the question, changed script.js. 正如我在问题中提到的,更改了script.js。 A line from 一条线从

if (oFile.size > 250* 1024)

to

if (oFile.size > 2048 * 2048)

And lastly to be able to save the image in the cropping size rather not in some pre-defined size, I added an extra line of 最后,为了能够以裁切大小而不是以某些预定义的大小保存图像,我添加了一条额外的

$iHeight=(int)$_POST['h']; $iWidth=(int)$_POST['w'];

before this line 在这行之前

$vDstImg = @imagecreatetruecolor( $iWidth, $iHeight );

Then the image will be saved in exact same size as cropped in preview. 然后,图像将以与预览中裁切的完全相同的尺寸保存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM