File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 141141 // Third party service providers
142142 Barryvdh \DomPDF \ServiceProvider::class,
143143 Barryvdh \Snappy \ServiceProvider::class,
144- Intervention \Image \ImageServiceProvider::class,
145144 SocialiteProviders \Manager \ServiceProvider::class,
146145
147146 // BookStack custom service providers
161160 // Laravel Packages
162161 'Socialite ' => Laravel \Socialite \Facades \Socialite::class,
163162
164- // Third Party
165- 'ImageTool ' => Intervention \Image \Facades \Image::class,
166-
167163 // Custom BookStack
168164 'Activity ' => BookStack \Facades \Activity::class,
169165 'Theme ' => BookStack \Facades \Theme::class,
Original file line number Diff line number Diff line change 66use Exception ;
77use GuzzleHttp \Psr7 \Utils ;
88use Illuminate \Support \Facades \Cache ;
9+ use Intervention \Image \Gd \Driver ;
910use Intervention \Image \Image as InterventionImage ;
10- use Intervention \Image \ImageManager ;
1111
1212class ImageResizer
1313{
1414 protected const THUMBNAIL_CACHE_TIME = 604_800 ; // 1 week
1515
1616 public function __construct (
17- protected ImageManager $ intervention ,
1817 protected ImageStorage $ storage ,
1918 ) {
2019 }
@@ -117,7 +116,7 @@ public function resizeImageData(
117116 ?string $ format = null ,
118117 ): string {
119118 try {
120- $ thumb = $ this ->intervention -> make ($ imageData );
119+ $ thumb = $ this ->interventionFromImageData ($ imageData );
121120 } catch (Exception $ e ) {
122121 throw new ImageUploadException (trans ('errors.cannot_create_thumbs ' ));
123122 }
@@ -144,6 +143,17 @@ public function resizeImageData(
144143 return $ thumbData ;
145144 }
146145
146+ /**
147+ * Create an intervention image instance from the given image data.
148+ * Performs some manual library usage to ensure image is specifically loaded
149+ * from given binary data instead of data being misinterpreted.
150+ */
151+ protected function interventionFromImageData (string $ imageData ): InterventionImage
152+ {
153+ $ driver = new Driver ();
154+ return $ driver ->decoder ->initFromBinary ($ imageData );
155+ }
156+
147157 /**
148158 * Orientate the given intervention image based upon the given original image data.
149159 * Intervention does have an `orientate` method but the exif data it needs is lost before it
You can’t perform that action at this time.
0 commit comments