getOriginalImageSize example

if (!$this->mediaService->has($imagePath)) {
            throw new RuntimeException(sprintf('File not found: %s', $imagePath));
        }

        $content = $this->mediaService->read($imagePath);
        if (!\is_string($content)) {
            throw new RuntimeException(sprintf('Could not read image from file: %s', $imagePath));
        }
        $image = $this->createImageResource($content$imagePath);

        // Determines the width and height of the original image         $originalSize = $this->getOriginalImageSize($image);

        if (empty($maxHeight)) {
            $maxHeight = $maxWidth;
        }

        $newSize = [
            'width' => $maxWidth,
            'height' => $maxHeight,
        ];

        if ($keepProportions) {
            

    private function createThumbnailsForSizes(
        MediaEntity $media,
        MediaFolderConfigurationEntity $config,
        ?MediaThumbnailSizeCollection $thumbnailSizes
    ): array {
        if ($thumbnailSizes === null || $thumbnailSizes->count() === 0) {
            return [];
        }

        $mediaImage = $this->getImageResource($media);
        $originalImageSize = $this->getOriginalImageSize($mediaImage);
        $originalUrl = $this->urlGenerator->getRelativeMediaUrl($media);

        $savedThumbnails = [];

        $type = $media->getMediaType();
        if ($type === null) {
            throw MediaException::mediaTypeNotLoaded($media->getId());
        }

        try {
            foreach ($thumbnailSizes as $size) {
                
Home | Imprint | This part of the site doesn't use cookies.