@@ -302,22 +302,31 @@ protected function regenerateNewImages(string $dir, array $type, bool $productsI
302
302
if (file_exists ($ existing_img ) && filesize ($ existing_img )) {
303
303
foreach ($ type as $ imageType ) {
304
304
if (!file_exists ($ dir . $ imageObj ->getExistingImgPath () . '- ' . stripslashes ($ imageType ['name ' ]) . '.jpg ' )) {
305
- if (!ImageManager::resize ($ existing_img , $ dir . $ imageObj ->getExistingImgPath () . '- ' . stripslashes ($ imageType ['name ' ]) . '.jpg ' , (int ) $ imageType ['width ' ], (int ) $ imageType ['height ' ])) {
306
- $ this ->errors [] = sprintf (
307
- 'Original image is corrupt %s for product ID %s or bad permission on folder. ' ,
308
- $ existing_img ,
309
- (int ) $ imageObj ->id_product
310
- );
311
- }
312
-
313
- if ($ generate_hight_dpi_images ) {
314
- if (!ImageManager::resize ($ existing_img , $ dir . $ imageObj ->getExistingImgPath () . '- ' . stripslashes ($ imageType ['name ' ]) . '2x.jpg ' , (int ) $ imageType ['width ' ] * 2 , (int ) $ imageType ['height ' ] * 2 )) {
305
+ try {
306
+ if (!ImageManager::resize ($ existing_img , $ dir . $ imageObj ->getExistingImgPath () . '- ' . stripslashes ($ imageType ['name ' ]) . '.jpg ' , (int ) $ imageType ['width ' ], (int ) $ imageType ['height ' ])) {
315
307
$ this ->errors [] = sprintf (
316
308
'Original image is corrupt %s for product ID %s or bad permission on folder. ' ,
317
309
$ existing_img ,
318
310
(int ) $ imageObj ->id_product
319
311
);
320
312
}
313
+
314
+ if ($ generate_hight_dpi_images ) {
315
+ if (!ImageManager::resize ($ existing_img , $ dir . $ imageObj ->getExistingImgPath () . '- ' . stripslashes ($ imageType ['name ' ]) . '2x.jpg ' , (int ) $ imageType ['width ' ] * 2 , (int ) $ imageType ['height ' ] * 2 )) {
316
+ $ this ->errors [] = sprintf (
317
+ 'Original image is corrupt %s for product ID %s or bad permission on folder. ' ,
318
+ $ existing_img ,
319
+ (int ) $ imageObj ->id_product
320
+ );
321
+ }
322
+ }
323
+ } catch (\Exception $ e ) {
324
+ $ this ->errors [] = sprintf (
325
+ 'Unable to resize image %s for product ID %s. error: %s ' ,
326
+ $ existing_img ,
327
+ (int ) $ imageObj ->id_product ,
328
+ $ e ->getMessage ()
329
+ );
321
330
}
322
331
}
323
332
}
0 commit comments