@@ -102,20 +102,20 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
102102 $ path = $ this ->getConvertedFilePath ($ files [0 ]);
103103 if (in_array ($ model , [ImagenetClassifier::MODEL_NAME , LandmarksClassifier::MODEL_NAME , ClusteringFaceClassifier::MODEL_NAME ], true )) {
104104 // Check file data size
105- $ filesize = filesize ($ path );
106- if ($ filesize !== false ) {
107- $ filesizeMb = $ filesize / (1024 * 1024 );
108- if ($ filesizeMb > 8 ) {
109- $ this ->logger ->debug ('File is too large for classifier: ' . $ files [0 ]->getPath ());
110- try {
111- $ this ->logger ->debug ('removing ' . $ queueFile ->getFileId () . ' from ' . $ model . ' queue ' );
112- $ this ->queue ->removeFromQueue ($ model , $ queueFile );
113- } catch (Exception $ e ) {
114- $ this ->logger ->warning ($ e ->getMessage (), ['exception ' => $ e ]);
115- }
116- continue ;
117- }
118- }
105+ $ filesize = filesize ($ path );
106+ if ($ filesize !== false ) {
107+ $ filesizeMb = $ filesize / (1024 * 1024 );
108+ if ($ filesizeMb > 8 ) {
109+ $ this ->logger ->debug ('File is too large for classifier: ' . $ files [0 ]->getPath ());
110+ try {
111+ $ this ->logger ->debug ('removing ' . $ queueFile ->getFileId () . ' from ' . $ model . ' queue ' );
112+ $ this ->queue ->removeFromQueue ($ model , $ queueFile );
113+ } catch (Exception $ e ) {
114+ $ this ->logger ->warning ($ e ->getMessage (), ['exception ' => $ e ]);
115+ }
116+ continue ;
117+ }
118+ }
119119 // Check file dimensions
120120 $ dimensions = @getimagesize ($ path );
121121 if (isset ($ dimensions ) && $ dimensions !== false && ($ dimensions [0 ] > 1024 || $ dimensions [1 ] > 1024 )) {
@@ -348,13 +348,13 @@ public function generatePreviewWithProvider(File $file): string {
348348
349349 if (in_array ($ imagetype , [IMAGETYPE_WEBP , IMAGETYPE_AVIF , false ])) { // To troubleshoot if it is a webp or avif.
350350 $ imageString = file_get_contents ($ tmpname );
351- if ($ imageString === false ) {
352- throw new \OCA \Recognize \Exception \Exception ('Could not load preview file from temp folder ' );
353- }
354- $ previewImage = imagecreatefromstring ($ imageString );
355- if ($ previewImage === false ) {
356- throw new \OCA \Recognize \Exception \Exception ('Could not load preview file from temp folder ' );
357- }
351+ if ($ imageString === false ) {
352+ throw new \OCA \Recognize \Exception \Exception ('Could not load preview file from temp folder ' );
353+ }
354+ $ previewImage = imagecreatefromstring ($ imageString );
355+ if ($ previewImage === false ) {
356+ throw new \OCA \Recognize \Exception \Exception ('Could not load preview file from temp folder ' );
357+ }
358358 $ use_gd_quality = (int )\OCP \Server::get (IConfig::class)->getSystemValue ('recognize.preview.quality ' , '100 ' );
359359 if (imagejpeg ($ previewImage , $ tmpname , $ use_gd_quality ) === false ) {
360360 imagedestroy ($ previewImage );
@@ -372,20 +372,20 @@ public function generatePreviewWithProvider(File $file): string {
372372 * @throws \OCA\Recognize\Exception\Exception
373373 */
374374 public function generatePreviewWithGD (string $ path ): string {
375- $ imageContents = file_get_contents ($ path );
376- if (!$ imageContents ) {
377- throw new \OCA \Recognize \Exception \Exception ('Could not load image for preview with gdlib ' );
378- }
375+ $ imageContents = file_get_contents ($ path );
376+ if (!$ imageContents ) {
377+ throw new \OCA \Recognize \Exception \Exception ('Could not load image for preview with gdlib ' );
378+ }
379379 $ image = imagecreatefromstring ($ imageContents );
380380 if (!$ image ) {
381381 throw new \OCA \Recognize \Exception \Exception ('Could not load image for preview with gdlib ' );
382382 }
383383 $ width = imagesx ($ image );
384384 $ height = imagesy ($ image );
385385
386- if ($ width === false || $ height === false ) {
387- throw new \OCA \Recognize \Exception \Exception ('Could not get image dimensions for preview with gdlib ' );
388- }
386+ if ($ width === false || $ height === false ) {
387+ throw new \OCA \Recognize \Exception \Exception ('Could not get image dimensions for preview with gdlib ' );
388+ }
389389
390390 $ maxWidth = (float ) self ::TEMP_FILE_DIMENSION ;
391391 $ maxHeight = (float ) self ::TEMP_FILE_DIMENSION ;
0 commit comments