Hi there, I searched for an option to automatically resize images on upload to a maximum extension (width/height). I couldn’t find a solution just some hints from many years ago where it seemed not to be possible.
Is there, with a current CMS version, the possibility to configure automatic resize of images on upload? Or if not, is there the possibility to at least set a size limit (width/height)? And if both do not exist, how could an automatic resize be made possible?
I never tried this but if i had to i would use a PSR 15 http-component in Neos 7 where the uploaded files are accessible as UploadedFile object. That way the scaling could be done before the image is converted to a persistentResource.
This could even be implemented as a Framework agnostic psr15 component that only has imagine as dependency. It may even be possible to find an existing component that does exactly that. Nevertheless i had no success during a short search for that.
Offcourse you would have to be careful with that approach. If you scale the image down and later validate for minimum width you will end up in a mess. However as i understood this was mererely requested as a way to prevent ultralarge images beeing uploaded directly from digital cameras.
It would be a bit harder to limit upload image sizes this only for a specific usecase like forms. I would try to use a custom type converter in that case. But how to integrate this into the concrete case is another topic and i never actually tried that.
Absolutely correct. This and to prevent users from wasting diskspace on websites with many pictures and no need for very high resolutions. I know the described functionality as a standard feature from other CMS so I thought I should not be the first to think about it.
Thanks for your answers. So there is no such functionality in NEOS. And the requirements to implement this seem to be far beyond my knowledge. Never mind. Thank you.
The Neos.Media package has a singnal called assetCreated - you might find tha tuseful. Be aware, that if you change the original resource, you might have to re-create thumbnails etc, if it’s already created at that point
I could find out that Neos\Media\Domain\Service\AssetService seems to send such a signal. Apart from the sad fact that I don’t know anything about the wohle media package there is one major point that seems not to suite the requirements.
As I understand it the original (too large) picture is created anyway and also exists later on in NEOS. I would have to do my scaling work after the creation of the unwanted image. But the requirements on an image upload would be:
Create the image if it is not larger (width or height) than the configured maximum extension (e.g. 1920px).
If it is larger, first scale it down to the maximum extension and then create it.
Thanks for your info.
I would of course like to implement something but as already mentioned this is far beyond my knowledge. I hoped that if no configuration is possible there is at least a more simple way. For example I hoped for an event which is triggered while uploading and before saving and a function could be registered on that event whithin which the source image is available and can be manipulated before processing will be finished by NEOS. That would have been one place to do just one work, scaling. Reading an trying out that would have been many hours/days for a working solution. But there’s more to do and much more to know. This is out of my reach.
That’s great, you’re amazing!!!
At this moment I only can answer to that. My NEOS test project where I asked for that is over. Now I’m deep into a completely different topic. But if there will be some time I of course will try it out.
LOL Hiring you seems to be a good idea in general. But with this past project I tried to figure out if/how NEOS can fit the needs for future projects. So walking the way completely alone was part of the mission.