Compress/resize Images on upload

Permalink 1 user found helpful
Hey there,

i a looking for a way to compress an resize images while uploading.
some of my clients only get high-res images and it is to complicated for them to use an image-editor an resize the images to a specific format and resolution.
i only found this thread:
http://www.concrete5.org/community/forums/customizing_c5/automatic-...

can anybody help me with this issue?

difference
 
mnakalay replied on at Permalink Reply
mnakalay
It is actually already included in Concrete5 5.7.

In your dashboard, go to System & Settings, then got to files and then thumbnails

There create a new thumbnail type specifying a width and height.

Once your thumbnail type is created, that type will be created for any new image uploaded.

If yo have 5 active types for instance, upload an image and automatically the image will be resized to create the 5 types defined and will also leave the original intact.

Your code then will have to be able to select the proper type for use.
rockface replied on at Permalink Reply
rockface
Creating a new thumbnail will retain the existing file in it's original size.

In my case, (a photo club) we have about 100 hobby photographers uploading 18 to 42 megapixel images. We can't get them to understand images that size are insanely large for a website gallery.

Since I rolled my own file upload form, I added this code to the controller file to re-size the original image after adding it to the users' personal fileset:

$file = $myFileObject->getFile();
$fID = $file->getFileID();
$FilePath = str_replace("//","/",$_SERVER["DOCUMENT_ROOT"] . $file->getRelativePath());
//Add file to user fileset
...
//Resize file   
$file_info = getimagesize($FilePath );
$w = $file_info[0];
$h = $file_info[1];   
$maxW = $this->maxFileWidth;
$maxH = $this->maxFileHeight;
if( (($file_info[2] == 1) || ($file_info[2] == 2) || ($file_info[2] == 3) )&&($w > $maxW || $h > $maxH) ) {
   $ih = Core::make('helper/image');
   $ih->create($FilePath, $FilePath, $this->maxFileWidth, $this->maxFileHeight, false);
   $file_info = getimagesize($FilePath );


To make this work, I have a maxFileWidth and maxFileHeight setting in the block install page. The block creates a personal image gallery on the profile page and is also used to upload images to on-line photo contests. The package using this code will be coming to the C5 5.7 market place soon... in the form of a new add-on called "Photo Contest". Our club is a member of the PSA and the C5 package has several different types of photo contests depending on how judging and the resulting gallery should look like.

Sorry to make a pitch for my new package, but I think the code snipit above might help you get your images re-sized.

Hope this helps.
Steevb replied on at Permalink Reply
Steevb
But does it reduce the weight of the image. i.e. 5MB - to 150KB?
rockface replied on at Permalink Reply
rockface
Yes! :-) This was very important to us! Our club's photo contests receive 200+ images a month. The old (5.6) photo contest block just rejected entries that were too large and made them resize it and upload again, the new (5.7) version resizes it automatically - MUCH nicer approach.

The file upload and integrated photo judging bits are mostly working, I only need to add a community points dashboard page and "contest winner - image slider" block. Should be ready for our go-live date of 1/1/2016
MrKDilkington replied on at Permalink Reply
MrKDilkington
@difference

Community member Mesuva is working on a feature to add image resizing of uploaded images.

Client side image resizing (discussion) #3147
https://github.com/concrete5/concrete5/issues/3147...
rockface replied on at Permalink Reply
rockface
Thanks, that would be awesome once it's built into C5. The only difference here is my approach controls at the block level allowing each block instance to be unique (if desired). This is likely never going to be different on a website, so the dashboard approach is still awesome.
gavthompson replied on at Permalink Reply
gavthompson
Mesuva's feature would be fantastic... but I have come across an "issue" that goes in hand with this.

When uploading multiple files of a larger file size the Upload Progress bar is very inaccurate and misleading.
On Friday during a demo to a user they uploaded 20 images and the progress bar reached 100% long before the upload was finished and I was sat there telling the users "it is doing it, I promise....you just have to wait a bit longer". When it hits 100% so early on there is no indication of whether it is still working or not and your average user has no patience theses days.

What would be great is if the Upload Progress bar was more accurate, or better still if you had individual progress bars for each item being loaded in a visual queue.

No idea how hard this would be but I think it would be a massive benefit to the File Manager interface.
Steevb replied on at Permalink Reply
Steevb
Which browser were you using?

Firefox?
gavthompson replied on at Permalink Reply
gavthompson
IE11
Steevb replied on at Permalink Reply
Steevb
Try using Chrome
gavthompson replied on at Permalink Reply
gavthompson
Not really much of an option for us Steevb, We only run IE here.
Steevb replied on at Permalink Reply
Steevb
Not much help I know, but I try/force my clients to use 'PhotoScape'. Bit of training and with two clicks (normally) images are optimised and resized.

It's free:http://photoscape.org/ps/main/index.php...
mesuva replied on at Permalink Reply
mesuva
This app looks good. I've never really found a batch resize app for the mac that I like (they've always been a bit clunky). This one seems to work well, on mac at least.

Thanks for sharing.

As a sidenote, I've done a pull request for the client-side resizing, so this really just need to be reviewed and/or tweaked. If anyone wants to test it out, they can grab my branch from github and set it up (set up the dev way, it needs composer and grunt)
gavthompson replied on at Permalink Reply
gavthompson
Thanks Steevb I'll have to check it out.