Hello again. I|m having some issues with uploading above certain image dimensions. If I try uploading an image with the dimensions 3280 x 4928 px, the upload outputs the error message: āInvalid API methodā. Uploading a downsized version of the same image with 2172 x 3263 px works well. It seems, that the file size doesnāt matter. (if I compress the bigger dimensions to a smaller filesize than the smaller dimensions, the bigger dimensions still fail to upload)
Is there a restriction to max. dimensions?
Thanks for any help!
My info.php says:
upload_max_filesize: 32M
post_max_size: 48M
memory_limit: 128M
Here the upload hook of my my config.php:
c::set('panel.upload.post', function($file, $uploadData) {
$fileurl = $file->url();
$filedir = $file->dir();
$original_fileurl = $fileurl . '/' . 'original-img';
$original_filedir = $filedir . DS . 'original-img';
$resized_fileurl = $fileurl . '/' . 'resized-img';
$resized_filedir = $filedir . DS . 'resized-img';
$resized_quality = 90;
//!!Upload hook only for images!
if ($file->type() == 'image') {
$imageconvert1 = new ImageConverter($file, array(
//For image 480 x 1000 (FullWidth)
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 480,
'height' => 1000,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_480x1000.{extension}',
'autoOrient' => true,
));
$imageconvert1_x2 = new ImageConverter($file, array(
//For image 800 x 600 (FullWidth) @2X
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 1600,
'height' => 1200,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_480x1000_@2x.{extension}',
'autoOrient' => true,
));
$imageconvert2 = new ImageConverter($file, array(
//For image 1024 x 768 (FullWidth)
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 1024,
'height' => 768,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_1024x768.{extension}',
'autoOrient' => true,
));
$imageconvert2_x2 = new ImageConverter($file, array(
//For image 1024 x 768 (FullWidth)
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 2048,
'height' => 1536,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_1024x768_@2x.{extension}',
'autoOrient' => true,
));
$imageconvert3 = new ImageConverter($file, array(
//For image 1280 x 960 (2/3-Width)
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 960,
'height' => 1080,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_960x1080.{extension}',
'autoOrient' => true,
));
$imageconvert3_x2 = new ImageConverter($file, array(
//For image 1024 x 768 (FullWidth)
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 1920,
'height' => 2160,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_960x1080_@2x.{extension}',
'autoOrient' => true,
));
$imageconvert4 = new ImageConverter($file, array(
//For image 1920 x 1440 (2/3-Width), as DEFAULT IMAGE!!
'url' => $fileurl,
'root' => $filedir,
'width' => 1280,
'height' => 1440,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah.{extension}',
'autoOrient' => true,
));
$imageconvert4_x2 = new ImageConverter($file, array(
//For image 1920 x 1440 (2/3-Width), as DEFAULT IMAGE!! @2x
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 2560,
'height' => 2880,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_@2x.{extension}',
'autoOrient' => true,
));
$imageconvert5 = new ImageConverter($file, array(
//For image anything above 1920 x 1440
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 1800,
'height' => 1920,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_1800x1920.{extension}',
'autoOrient' => true,
));
$imageconvert5_x2 = new ImageConverter($file, array(
//For image 1920 x 1440 (2/3-Width), as DEFAULT IMAGE!!
'url' => $resized_fileurl,
'root' => $resized_filedir,
'width' => 3600,
'height' => 3840,
'upscale' => false,
'quality' => $resized_quality,
'filename' => '{name}_bah_1800x1920_@2x.{extension}',
'autoOrient' => true,
));
//!!Create ORIGINAL directory, IF doesn't exist
if (!file_exists($original_filedir)) {
mkdir($original_filedir, 0777, true);
}
//!!Create RESIZED directory, IF doesn't exist
if (!file_exists($resized_filedir)) {
mkdir($resized_filedir, 0777, true);
}
//!!Process the set up conversions
$imageconvert1->process();
$imageconvert1_x2->process();
$imageconvert2->process();
$imageconvert2_x2->process();
$imageconvert3->process();
$imageconvert3_x2->process();
$imageconvert4->process();
$imageconvert4_x2->process();
$imageconvert5->process();
$imageconvert5_x2->process();
//!!At the end, move original upload to ORIGINAL-folder
$file->move($original_filedir . DS . $file->filename());
}
});