Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the size of the original uploaded files (advice) #1340

Open
csrui opened this issue Nov 28, 2015 · 5 comments
Open

Reduce the size of the original uploaded files (advice) #1340

csrui opened this issue Nov 28, 2015 · 5 comments

Comments

@csrui
Copy link

csrui commented Nov 28, 2015

Let me start by stating that limiting the size of the uploads is not a good option as many users don't know or have the tools to do so.

The uploads folder size can get out of hand really quick so I would like to script something to reduce the size of the original images in the background with a cronjob. I would like to ask for advice on how to do this. Should I do this as a module (If so any reference link where I can start looking) or as a standalone script to upload somewhere?

Sugestions welcome.

@ghost
Copy link

ghost commented Nov 28, 2015

You could use php script with GD or imagemagic commands or php script to do that:
GD: http://zenverse.net/php-reducing-image-filesize-using-gd/
Imagemagic: http://php.net/manual/en/imagick.setimagecompression.php

@WASasquatch
Copy link
Contributor

I believe you can simple add quality to the images being stored. Look at
the file system code.

On Sat, Nov 28, 2015 at 10:50 AM, Łukasz Szczepański <
notifications@github.com> wrote:

You could use php script with GD or imagemagic commands or php script to
do that:
GD: http://zenverse.net/php-reducing-image-filesize-using-gd/
Imagemagic: http://php.net/manual/en/imagick.setimagecompression.php


Reply to this email directly or view it on GitHub
#1340 (comment).

Sincerely,
Jordan S. C. Thompson *
*Web Development & Design Coordinator

@csrui
Copy link
Author

csrui commented Nov 30, 2015

The code seems to be located here:

protected function handleFileUpload($cFile, $object = null)

I was thinking that there should be an option on the admin size to configure maximum size of the images and then on the upload do the resize automaticaly based on the previous setting. What do you guys think?

@csrui csrui changed the title Cronjob to reduce the size of the original uploaded files (advice) Reduce the size of the original uploaded files (advice) Nov 30, 2015
@rondonjon
Copy link

rondonjon commented Jul 17, 2016

Although I basically support the idea, I don't like the solution you're suggesting, @csrui

Resizing usually also reduces quality, too, and loss of quality is sometimes undesired.

I would suggest a combined solution that serves all cases, by creating additional, "preview" images and still keeping the original image in case it is later needed, e.g. when somebody clicks on the preview images.

Also, I would advise against fixed sizes for preview images. Think of mobile devices and what so-called responsive image can/must do today. With device ranges from low-budget Android phones over retina-depth pixels on iPad to demos running on a presentation screen: the age of fixed-size images is over, one resolution can't serve all the needs.

@csrui
Copy link
Author

csrui commented Jul 18, 2016

It does reduce quality but I believe that it should be an administrative option.
Let's leave it for each site administrator to choose.
Without limits, the server space requirements will grow out of hand in no time.

The system should generate N configurable sizes from the main image to use as @rondonjon notes. Using img srcset, several sizes could be available for different resolutions and such. Keeping the original fullsize image is another option all together :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

5 participants