1

Currently I trying to regenerate image from current format .png to default (jpg).. But I notice that I generate new file with new format.. So now have images with format .png and .jpg.. So how can I replace the old format or delete it.. From my study can use command provided by spatie either clear or clean.. But its the best way or there is any other ways? Thanks in advance..

I'm using spatie media library v8 https://spatie.be/docs/laravel-medialibrary/v8/introduction

This is the old

So currently I want to use default format which is jpg

So basically I need to regenerate all the old images. However because new changes is different format it will create new image where the final result will have two images (img.png and img.jpg). I have more than 400k of images, so I need be careful in this.

So is there any solution or the only is to use command clean/clear provides by the package.

apokryfos
  • 38,771
  • 9
  • 70
  • 114
shahrizal
  • 21
  • 5

1 Answers1

1

After you run the conversion with the new specification with php artisan media-library:regenerate, I believe the best way is to just run php artisan media-library:clean and that will remove any images from the previous unused conversion setup. If disk space is an issue, you can clean before you regenerate - though that will cause some broken images until all the images are regenerated. So you might want to break up the process using ids: php artisan media-library:regenerate --ids=1,2,3 or the specific model: php artisan media-library:regenerate "App\Models\Post"

More at: https://spatie.be/docs/laravel-medialibrary/v9/converting-images/regenerating-images

Nathan
  • 1,483
  • 3
  • 18
  • 41