2

您好,我正在使用一个名为 aurigma 的基于 java 的图像上传器,并使用 php 代码进行设置。

我有一些可以在宽度或高度上设置的调整大小选项。

我想检查一下我说的地方:

If ((image I am uploading width) > (image I am uploading height)){
   $converter->setThumbnailFitMode("Width");
}else{
   $converter->setThumbnailFitMode("Height");
}

如何检查我上传到 aurigma 的文件大小并基于此设置条件。IE

4

2 回答 2

1

如果您需要在运行时设置转换器,您需要设置两个额外的 aurigma 上传器事件:1.BeforeUpload 和 2.BeforePackageUpload:

  uploader = new Uploader('Uploader1');
    ...
    $uploader->getClientEvents()->setBeforeUpload("BeforeUpload");
    $uploader->getClientEvents()->setBeforePackageUpload("BeforePackageUpload");
    ...

然后在 Javascript 块中实现事件代码(脚本类型 = “text/javascript”)。

您将需要获取添加到上传窗格的所有图像的宽度和高度,并将这些值放入数组中。在 BeforePackageUpload 中,您应该获取每个文件的宽度和高度值并比较它们以设置所需的转换器适合模式:

//set new arrays 
var widths = [];
var heights = [];

function BeforeUpload() {
  var uploader = $au.uploader('Uploader1');
  count = uploader.files().count();
  for (i = 0; i < count; i++) {
    widths[i] = uploader.files().get(i).width();
    heights[i] = uploader.files().get(i).height();
  }
}

function BeforePackageUpload(index) {
  var uploader = $au.uploader('Uploader1');
  if (widths.shift() > heights.shift()) {
    uploader.converters([{
      mode: '*.*=Thumbnail',
      thumbnailFitMode: 'Width',
      thumbnailWidth: 500,
      thumbnailHeight: 300,
      thumbnailJpegQuality: 100
    }]);
  }

  else  
  {
    uploader.converters([{
      mode: '*.*=Thumbnail',
      thumbnailFitMode: 'Height',
      thumbnailWidth: 300,
      thumbnailHeight: 500,
      thumbnailJpegQuality: 100
    }]);
  }
}
于 2012-04-25T05:02:09.487 回答
0

看看: http: //php.net/manual/en/book.image.php

于 2012-04-24T14:46:24.067 回答