aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Preview/Generator.php
Commit message (Collapse)AuthorAgeFilesLines
* feat: add width, height, crop and mode to BeforePreviewFetchedEventDaniel Kesselberg2023-06-231-2/+6
| | | | | | | | | | | | | | user_usage_report keeps a counter for files read. The app uses - OC_Filesystem::read hook - Event listener (the legacy one) for IPreview::EVENT Request for previews do not trigger the hook, hence the additional event listener. The thumbnails for a list or grid view should not count, so we need the width and height. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
* Merge pull request #38261 from fsamapoor/replace_strpos_calls_in_lib_privateRobin Appelman2023-06-011-1/+1
|\ | | | | Refactors "strpos" calls in lib/private to improve code readability.
| * Refactors "strpos" calls in lib/private to improve code readability.Faraz Samapoor2023-05-151-1/+1
| | | | | | | | Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
* | Merge pull request #36692 from ↵Simon L2023-05-171-0/+4
|\ \ | |/ |/| | | | | nextcloud/throw-exception-to-avoid-division-by-zero fix(preview-generator): Throw exception before dividing by zero when generating previews
| * fix(preview-generator): Throw exception before dividing by zero when ↵Thomas Citharel2023-02-131-0/+4
| | | | | | | | | | | | | | | | | | generating previews If the maximum preview generated gives some kind of invalid IImage, it's dimentions and filename can be set to zero. And then later we do a division by zero to keep the aspect ratio of the previews. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
* | Fix typos in lib/public subdirectorySimon L2023-05-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Found via `codespell -q 3 -S l10n -L jus ./lib/public` Signed-off-by: luz paz <luzpaz@github.com> Update lib/public/Accounts/IAccount.php Signed-off-by: luz paz <luzpaz@github.com> Signed-off-by: Simon L <szaimen@e.mail.de> Co-Authored-By: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
* | try to make linters happyGlandos2023-04-171-2/+2
| | | | | | | | Signed-off-by: Glandos <bugs-github@antipoul.fr>
* | gather code from small and max previewGlandos2023-04-171-90/+36
| | | | | | | | | | | | | | use directory listing in both functions to gain 25% speed on run where every preview already exist. Signed-off-by: Glandos <bugs-github@antipoul.fr>
* | Revert 0e49b40Glandos2023-04-171-3/+0
| | | | | | Signed-off-by: Glandos <bugs-github@antipoul.fr>
* | improve parameter docGlandos2023-04-171-1/+1
| | | | | | Signed-off-by: Glandos <bugs-github@antipoul.fr>
* | Ensure max preview image is not nullGlandos2023-04-171-0/+3
| | | | | | Signed-off-by: Glandos <bugs-github@antipoul.fr>
* | php-cs-fixGlandos2023-04-171-1/+1
| | | | | | Signed-off-by: Glandos <bugs-github@antipoul.fr>
* | List preview directory only onceGlandos2023-04-171-5/+13
|/ | | | | | getCachedPreview used to call `getFile`, and this calls `getDirectoryListing` (or underlying function that list directory) to find the file. This was done for every preview spec. Now, this is done only once at the beginning of the loop, and the array is just iterated when needed to find the correct entry. Signed-off-by: Glandos <bugs-github@antipoul.fr>
* composer run cs:fixCôme Chilliet2023-01-201-1/+0
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Limit-number-of-concurrent-preview-generationsszaimen2022-11-051-20/+125
| | | | | Signed-off-by: Bowen Ding <dbw9580@live.com> Signed-off-by: szaimen <szaimen@e.mail.de>
* Emit typed event when preview is requestedJulius Härtl2022-10-271-9/+12
| | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* Use Image class from public APIChristopher Ng2022-06-021-1/+1
| | | | Signed-off-by: Christopher Ng <chrng8@gmail.com>
* Merge pull request #32410 from nextcloud/bugfix/noid/imaginary-exceptionJohn Molakvoæ2022-05-201-2/+7
|\
| * Add explicit return if getSmallImagePreview failsJulius Härtl2022-05-191-2/+7
| | | | | | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* | Fix crop conditionCarl Schwan2022-05-191-4/+11
| | | | | | | | | | | | | | | | Make sure that when fetching the image from the cache we don't accidentally fetch the cropped image just because it also start with 256-256 Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Fix cropped image generated when not askedCarl Schwan2022-05-171-1/+2
|/ | | | | | | The $crop parameter was not propagated to the imaginary pipeline and instead it used the smartcrop algorithm always Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* Fix preview generator trying to recreate an existing folderRichard Steinmetz2022-05-091-2/+10
| | | | Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
* Generate small preview straight away if Imaginary is enabledJohn Molakvoæ2022-04-061-2/+7
| | | | Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
* Send images to imaginary docker to generate previewsVincent Petry2022-03-171-1/+81
| | | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu> Co-Authored-by: Vincent Petry <vincent@nextcloud.com>
* Properly log errors in Movie previews generationJohn Molakvoæ (skjnldsv)2021-08-191-0/+1
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Update php licensesJohn Molakvoæ (skjnldsv)2021-06-041-3/+3
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Use correct getSystemValue typeJ0WI2021-04-121-2/+2
| | | | Signed-off-by: J0WI <J0WI@users.noreply.github.com>
* Update the license headers for Nextcloud 20Christoph Wurst2020-08-241-0/+2
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Always try and show pre rendered previewScott Dutton2020-08-131-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Currently if the following situation happens Server generates preview Server has command removed which allows a preview to be shown Client asks for preview, gets a 404 error when preview exists (Mime checked before preview) This happens more often with documents, or video as the commands are not native PHP, they require a binary on the server. After the fix the following would happen Server generates preview Server has command removed which allows a preview to be shown Client asks for preview, gets preview which has been generated (Mime checked after preview) This would also allow offline generation (for example a docker image containing the extra binaries), allowing a reduction in attack surface of the instance serving the preview data. Signed-off-by: Scott Dutton <scott@exussum.co.uk>
* Use class that actually has the destroy() method in preview generatorMorris Jobke2020-08-051-1/+1
| | | | Signed-off-by: Morris Jobke <hey@morrisjobke.de>
* fix memory leak caused by not destroying image in Preview/Generate.phpElijah Martin-Merrill2020-07-271-0/+6
| | | | Signed-off-by: Elijah Martin-Merrill <elijah@nyp-itsours.com>
* Update license headers for 19Christoph Wurst2020-04-291-0/+1
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Merge pull request #19495 from nextcloud/preview-generate-batchRoeland Jago Douma2020-04-101-41/+71
|\ | | | | optimize batch generation of previews
| * fix preview generation testsRobin Appelman2020-04-101-2/+2
| | | | | | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
| * optimize batch generation of previewsRobin Appelman2020-04-091-7/+11
| | | | | | | | | | | | | | | | | | | | by allowing the generation of multiple previews at once we save on having to find, open and decode the max-preview for every preview of the same file the main use case for this is the preview generator app (pr for that comming next) in my local testing this saves about 25% of time when using the preview generator app Signed-off-by: Robin Appelman <robin@icewind.nl>
| * allow generating multiple preview sizes for a single file at onceRobin Appelman2020-04-091-34/+60
| | | | | | | | | | | | this saves having to do some of the overhead multiple times Signed-off-by: Robin Appelman <robin@icewind.nl>
* | Use elseif instead of else ifChristoph Wurst2020-04-101-1/+1
| | | | | | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* | Fix (array) indent style to always use one tabChristoph Wurst2020-04-091-3/+3
|/ | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Remove unused importsChristoph Wurst2020-03-251-2/+0
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Also center vertically when cropping previewsJohn Molakvoæ (skjnldsv)2019-12-221-1/+1
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Update license headersChristoph Wurst2019-12-051-1/+2
| | | | Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
* Some php-cs fixesRoeland Jago Douma2019-11-221-1/+1
| | | | | | | | | | | * Order the imports * No leading slash on imports * Empty line before namespace * One line per import * Empty after imports * Emmpty line at bottom of file Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* allow keeping multiple preview "versions" of the same fileRobin Appelman2019-07-081-17/+29
| | | | | | | | | | | The main use case here is storage provided versioning where we dont have separate file ids for all the versions, by allowing a prefix for the version we can store separate previews for all the versions. Additionally, by keeping all the version previews in the same folder as the "normal" previews they will be cleaned up properly when the file is deleted Signed-off-by: Robin Appelman <robin@icewind.nl>
* Allow IProviderV2 for previews as wellJohn Molakvoæ (skjnldsv)2019-07-051-2/+1
| | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* Add new Provider interface for preview providersRobin Appelman2019-06-171-3/+5
| | | | | | | | | the main difference is passing the `File` object to the provider instead of a `View` + path Old providers will still continue to work as before Signed-off-by: Robin Appelman <robin@icewind.nl>
* Only generate previews in powers of 4 and set minRoeland Jago Douma2018-10-311-7/+11
| | | | | | | | | | | | | | | Before we'd round up all preview request to their nearest power of two. This resulted still in a lot of possible images. Generating a lot of server load and taking up a lot of space. This moves it to previews to be powers of 4: 64, 256, 1024 and 4096 Also the first two powers are always skipped (4, 16) as it doesn't make sense to generate previews for that. We cache preview pretty agressively and I feel this is a better tradeoff. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Check if a preview provider is available before using itRoeland Jago Douma2018-08-171-0/+4
| | | | | | | | Else if a preview provider is registerd but not available (for example missing support in some external lib). It will do :boom:. This way the providers can at least do the sanity checks required. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Make sure the file is readable before attempting to create a previewRoeland Jago Douma2018-05-301-0/+6
| | | | Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* If the preview is size 0 it is invalidRoeland Jago Douma2018-01-221-3/+13
| | | | | | | | | * delete it * throw a NotFound Exception - This should a proper 404 to the user - Next time it is then regenerated Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Fix float/integer handling in image APIMorris Jobke2018-01-171-2/+2
| | | | | | | * IImage::crop/preciseResize now have type hinting for integers * found while testing strict typing for PHP 7+ Signed-off-by: Morris Jobke <hey@morrisjobke.de>