getimagesizefromstring example

static::assertInstanceOf(MediaThumbnailCollection::class$thumbnails);
        static::assertEquals(2, $thumbnails->count());

        foreach ($thumbnails as $thumbnail) {
            $path = $this->urlGenerator->getRelativeThumbnailUrl($media$thumbnail);
            static::assertTrue(
                $this->getPublicFilesystem()->has($path),
                'Thumbnail: ' . $path . ' does not exist'
            );

            $fileContents = $this->getPublicFilesystem()->read($path);
            $result = getimagesizefromstring($fileContents);

            static::assertIsArray($result);
            static::assertSame(499, $result[0]);
            static::assertSame(266, $result[1]);
        }
    }

    public function testGenerateThumbnailsWithSkipDeleteMessage(): void
    {
        $this->setFixtureContext($this->context);
        $media = $this->getPngWithFolder();

        


        if (!$this->isFormatSupported($media)) {
            return;
        }

        $mediaService = $this->container->get(MediaServiceInterface::class);

        if ((!$media->getHeight() || !$media->getWidth()) && $mediaService->has($media->getPath())) {
            switch ($media->getType()) {
                case Media::TYPE_IMAGE:
                    $imageSize = getimagesizefromstring((string) $mediaService->read($media->getPath()));
                    if (\is_array($imageSize)) {
                        [$width$height] = $imageSize;
                        break;
                    }

                    // no break                 case Media::TYPE_VECTOR:
                    if ($media->getExtension() === 'svg'
                        && $xml = simplexml_load_string($mediaService->read($media->getPath()))
                    ) {
                        /** @var SimpleXMLElement|null $attr */
                        
return 20 * log10($amplitude);
    }

    /** * @param string $imgData * @param array $imageinfo * * @return array|false */
    public static function GetDataImageSize($imgData, &$imageinfo=array()) {
        if (PHP_VERSION_ID >= 50400) {
            $GetDataImageSize = @getimagesizefromstring($imgData$imageinfo);
            if ($GetDataImageSize === false || !isset($GetDataImageSize[0]$GetDataImageSize[1])) {
                return false;
            }
            $GetDataImageSize['height'] = $GetDataImageSize[0];
            $GetDataImageSize['width'] = $GetDataImageSize[1];
            return $GetDataImageSize;
        }
        static $tempdir = '';
        if (empty($tempdir)) {
            if (function_exists('sys_get_temp_dir')) {
                $tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52
$retina,
                $row['maxWidth'],
                $row['maxHeight']
            );
        }

        return $thumbnails;
    }

    private function updateMedia(array $data): array
    {
        $imageSize = getimagesizefromstring((string) $this->mediaService->read($data['__media_path']));
        if (!\is_array($imageSize)) {
            throw new RuntimeException(sprintf('Could not get image size from "%s"', $data['__media_path']));
        }
        [$width$height] = $imageSize;
        $this->connection->executeUpdate(
            'UPDATE s_media SET width = :width, height = :height WHERE id = :id',
            [
                ':width' => $width,
                ':height' => $height,
                ':id' => $data['__media_id'],
            ]
        );
                                                        $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                                }
                                                break;

                                            case  1: // text flag                                             case 13: // image flag                                             default:
                                                $atom_structure['data'] = substr($boxdata, 8);
                                                if ($atomname == 'covr') {
                                                    if (!empty($atom_structure['data'])) {
                                                        $atom_structure['image_mime'] = 'image/unknown'; // provide default MIME type to ensure array keys exist                                                         if (function_exists('getimagesizefromstring') && ($getimagesize = getimagesizefromstring($atom_structure['data'])) && !empty($getimagesize['mime'])) {
                                                            $atom_structure['image_mime'] = $getimagesize['mime'];
                                                        } else {
                                                            // if getimagesizefromstring is not available, or fails for some reason, fall back to simple detection of common image formats                                                             $ImageFormatSignatures = array(
                                                                'image/jpeg' => "\xFF\xD8\xFF",
                                                                'image/png'  => "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A",
                                                                'image/gif'  => 'GIF',
                                                            );
                                                            foreach ($ImageFormatSignatures as $mime => $image_format_signature) {
                                                                if (substr($atom_structure['data'], 0, strlen($image_format_signature)) == $image_format_signature) {
                                                                    $atom_structure['image_mime'] = $mime;
                                                                    
Home | Imprint | This part of the site doesn't use cookies.