// Third party service providers
Barryvdh\DomPDF\ServiceProvider::class,
Barryvdh\Snappy\ServiceProvider::class,
- Intervention\Image\ImageServiceProvider::class,
SocialiteProviders\Manager\ServiceProvider::class,
// BookStack custom service providers
// Laravel Packages
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
- // Third Party
- 'ImageTool' => Intervention\Image\Facades\Image::class,
-
// Custom BookStack
'Activity' => BookStack\Facades\Activity::class,
'Theme' => BookStack\Facades\Theme::class,
use Exception;
use GuzzleHttp\Psr7\Utils;
use Illuminate\Support\Facades\Cache;
+use Intervention\Image\Gd\Driver;
use Intervention\Image\Image as InterventionImage;
-use Intervention\Image\ImageManager;
class ImageResizer
{
protected const THUMBNAIL_CACHE_TIME = 604_800; // 1 week
public function __construct(
- protected ImageManager $intervention,
protected ImageStorage $storage,
) {
}
?string $format = null,
): string {
try {
- $thumb = $this->intervention->make($imageData);
+ $thumb = $this->interventionFromImageData($imageData);
} catch (Exception $e) {
throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
}
return $thumbData;
}
+ /**
+ * Create an intervention image instance from the given image data.
+ * Performs some manual library usage to ensure image is specifically loaded
+ * from given binary data instead of data being misinterpreted.
+ */
+ protected function interventionFromImageData(string $imageData): InterventionImage
+ {
+ $driver = new Driver();
+ return $driver->decoder->initFromBinary($imageData);
+ }
+
/**
* Orientate the given intervention image based upon the given original image data.
* Intervention does have an `orientate` method but the exif data it needs is lost before it