Suporte do The Movie Database

Hi,

I'm having trouble reading a few of the original images with PHP. The image files download just fine, but I can not read the JPEG format.

The following PHP code fails.

$res = imagecreatefromstring(file_get_contents('http://image.tmdb.org/t/p/original/xz9xKoiKTUBjodNV1Evn9CAuMyq.jpg'));
var_dump($res === false);

outputs: false

If I attempt to download using one of the re-sized images, then it works fine.

$res = imagecreatefromstring(file_get_contents('http://image.tmdb.org/t/p/w1280/xz9xKoiKTUBjodNV1Evn9CAuMyq.jpg'));
var_dump($res === false);

outputs: true

This has started to happen only recently. I was wondering if anything with the processing of the images has changed.

p.s. All the images load fine in a browser (i.e. Chrome).

3 respostas (na página 1 de 1)

Jump to last post

Nothing really comes to mind. As per the other thread about webp, I would make sure you're getting the jpeg version (you should be, but just for a sanity check). So check the headers.

Webp aside, check the headers make sure everything looks good and normal. It could be something temporary as well.

Thanks for the response, and from what I can tell PHP 7.1.1 supports WebP and that shouldn't be the issue (but I'll need to verify that).

I thought the re-sized images would resolve this problem and switched from downloading the originals to those, but this has not helped the problem.

Today I'm seeing about 5% of images failing. Out of 1500 downloaded there are 60 that can't be read. I currently don't log the headers on the response, but I'll add that feature later today.

Now this has only been on my dev machine. I've not deployed to my production in a while, but this is in Ubuntu 14 bash with PHHP 7.1.1 on Windows 10.

What stack are you running? Is it PHP based?

Okay it turns out that all the problem images are WebP. It's also indicated in the headers that it's WebP.

I know PHP can read WebP but I guess the imagecreatefromstring method doesn't support it. I'll see if I can figure out a work around.

Does your server send JPEG if I change the "Accept:" header of the request to image/jpeg only, or will it still send WebP?

Não consegue encontrar um certo Filme ou Série? Inicie Sessão e adicione-o.

Geral

s focus the search bar
p abrir menu do perfil
esc close an open window
? open keyboard shortcut window

Em páginas de Média

b go back (or to parent when applicable)
e ir para a página de edição

Em Páginas de Temporadas de Séries

(seta para a direita) ir para a próxima temporada
(seta para a esquerda) ir para a temporada anterior

Em Páginas de Episódios de Séries

(seta para a direita) ir para o próximo episódio
(seta para a esquerda) ir para o episódio anterior

Em Todas as Páginas de Imagens

a abrir janela para adicionar imagem

Em Todas as Páginas de Edição

t open translation selector
ctrl+ s submit form

Em Páginas de Discussão

n criar uma nova discussão
w toggle watching status
p toggle public/private
c toggle close/open
a abrir actividade
r reply to discussion
l ir para a última resposta
ctrl+ enter submit your message
(seta para a direita) página seguinte
(seta para a esquerda) página anterior

Definições

Deseja classificar ou adicionar este item a uma lista?

Iniciar Sessão

Ainda não é um membro?

Crie uma Conta e Adere a Comunidade