Plant Image Loading
Current implementation
Plant icons are loaded from the Nextcloud instance.
The tested plant icons were 512x512 px PNG files.
Plant icons are expected to be relatively small, with a maximum size of 500 KB, and should use WebP where possible.
WebP is already used for plant icons where available. WebP usually provides smaller file sizes than JPEG or PNG while maintaining acceptable visual quality.
Nextcloud previews are already enabled, and the public Nextcloud preview endpoint can be used for plant icons.
Browser caching also works for plant icons.
Dynamic image resizing
Plant icons are currently loaded through the public WebDAV endpoint.
This loads the stored icon file directly, regardless of the size at which the icon is displayed on the map.
The public Nextcloud preview endpoint was tested as a possible way to load smaller plant icon previews.
The following icons and preview sizes were tested:
| Icon | Request | Returned dimensions | File size |
|---|---|---|---|
Ficus_carica.png | original | 512x512 | 152120 bytes |
Ficus_carica.png | 64x64 preview | 64x64 | 5201 bytes |
Ficus_carica.png | 128x128 preview | 256x256 | 44584 bytes |
Ficus_carica.png | 256x256 preview | 256x256 | 44584 bytes |
Ficus_carica.png | 500x500 preview | 512x512 | 146828 bytes |
Solanum_lycopersicum.png | original | 512x512 | 217373 bytes |
Solanum_lycopersicum.png | 64x64 preview | 64x64 | 5639 bytes |
Solanum_lycopersicum.png | 128x128 preview | 256x256 | 63051 bytes |
Solanum_lycopersicum.png | 256x256 preview | 256x256 | 63051 bytes |
Solanum_lycopersicum.png | 500x500 preview | 512x512 | 210389 bytes |
Eruca_sativa.png | original | 512x512 | 92971 bytes |
Eruca_sativa.png | 64x64 preview | 64x64 | 3333 bytes |
Eruca_sativa.png | 128x128 preview | 256x256 | 29623 bytes |
Eruca_sativa.png | 256x256 preview | 256x256 | 29623 bytes |
Eruca_sativa.png | 500x500 preview | 512x512 | 90235 bytes |
The tested icons show that smaller previews can significantly reduce file size.
This could be useful when the map is zoomed out because full-size plant icons are not necessary when they are displayed at a small size.
Preview size behavior
Nextcloud does not return every requested preview size exactly.
For the tested icons:
- requesting a 64x64 preview returned a 64x64 image;
- requesting a 128x128 preview returned a 256x256 image;
- requesting a 256x256 preview returned a 256x256 image;
- requesting a 500x500 preview returned a 512x512 image.
Dynamic plant icon resizing should therefore use only a small number of supported size buckets.
Based on the tested results, useful buckets would likely be:
- 64 px;
- 256 px;
- 512 px.
Using many closely spaced preview sizes would provide little benefit because Nextcloud may return the same generated image for several requested sizes.
Expected benefits
Because the current WebDAV images are cached by the browser, the expected benefits of smaller previews are primarily:
- reduced initial loading time;
- reduced image-decoding cost;
- lower memory usage.
It is not guaranteed that dynamic previews would significantly improve panning or zooming performance.
A final implementation should therefore be benchmarked on the map before dynamic preview-size switching is added.
Browser caching
Browser caching was checked using Ficus_carica.png.
After the first request, the icon was loaded from the browser disk cache.
Repeated network loading is therefore probably not the main performance problem for plant icons that have already been loaded.
Caching behavior should be checked again if the image-loading implementation is changed to use preview URLs, because different preview sizes would use different URLs and could create separate cached resources.
Nextcloud documentation
See the Nextcloud preview configuration documentation:
https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/previews_configuration.html