How to resize images before upload to server

Greetings,

I’m new in scriptcase and I need to resize images for a form before them upload to the server, i’m trying to use the “wideimage” (http://wideimage.sourceforge.net/documentation/manipulating-images/) library but it dont work i spected.

Here is the code i use on the “onBeforeInsert” event.

Image Field name: ImageName

sc_include_library(“prj”, “wideimage”, “WideImage.php”, true, true);
$image = WideImage::load({ImageName});
$resized = $image->resize(1280, 1280);
$img_resized = $resized->asString(‘jpg’, 80);
{ImageName} = $img_resized;

If are other solution to this problem please share me!

2 Likes

any luck?
if you solved please shere it… i am searching just the same stuff

fer

Do you you solved, i need to do same things?

Hi, i need resize images before upload to server, with multi-upload Scriptcase.
my Users take photos hight resultion from mobiles, and they must upload their photos with multi-upload scriptcase

Any Idea how resize images before upload, how can do it?

As upload is a php function, there is not much you can do actually, at least not with the standard functionality of SC. There are alternative ways, but to my experience it might be hard to implement. But a good start might be: javascript - Use HTML5 to resize an image before upload - Stack Overflow

Thanks you Aducom,
We hope that SC TEAM will soon include new features in future versions for images.

You could have users resize their images here before uploading.

http://www.simpleimageresizer.com/

Hello everyone.

When uploading the files, scriptcase places the images in the temporary file

Under development the folder for me is D:\NetMake\v9-php73\wwwroot\scriptcase\tmp
I uploaded 2 files excel.jpg and structurexcel.png

OnBeforeupdade you can get the names with the following script

if ( isset($_SESSION[‘sc_session’][$this->Ini->sc_page][‘form_parametros’][‘upload_field_ul_name’]) ) {
print_r($_SESSION[‘sc_session’][$this->Ini->sc_page][‘form_parametros’][‘upload_field_ul_name’]);
}

Array contains the names

Array ( [35988b123e6d975b3438aec40bceff09] => sc_4034279b_excel.jpg [5b59d7c0dafc81f11479752670eb64fe] => sc_f0bbf4dd_structurexcel.png )

Now you can use the script to reduce the size of the files.

Any additional suggestions are welcome.