Bug #92455

createFile with file image extension causes ImageMagick identify errors

Added by RVVN no-lastname-given about 2 months ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2020-09-30
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hi,

since 9.5.22, creating file with an image extension ("jpeg", "jpg", "png") with Storage->createFile() causes the following errors from ImageMagick "identify" function :


identify: insufficient image data in file `/xxxxxxxx/xxxxxx/375536226116427_1338295523173821.jpeg' @ error/jpeg.c/ReadJPEGImage/1039.

identify: improper image header `/xxxxxxxx/xxxxxx/1675979572678151_2805251863084244.png' @ error/png.c/ReadPNGImage/3954.

This is because Indexing is invoked during the file creation, and Indexer extract width and height but these metadata (via ImageMagick "identify") don't exist yet.

As a side question, why indexing at file creation ?

#1

Updated by Helmut Hummel about 2 months ago

RVVN no-lastname-given wrote:

since 9.5.22, creating file with an image extension ("jpeg", "jpg", "png") with Storage->createFile() causes the following errors from ImageMagick "identify" function :

Can you elaborate what exactly the error is you are seeing? How do these error from Imagemagick affect your goals? Are you seeing any exceptions?

As a side question, why indexing at file creation ?

That is how FAL works. Any file that is added will get an index entry.

#2

Updated by RVVN no-lastname-given about 2 months ago

We have a scheduler cron job that fetches remote images then stores them in fileadmin.
Images are well created at the end, but we receive emails with the mentioned errors.

TYPO3 logs warnings too :

component="TYPO3.CMS.Core.Type.File.ImageInfo": I could not retrieve the image size for file /xxxxxxxx/xxxxxx//381438182400366_776716469539200.jpeg

We use the following sequence :

  1. storage->createFile(filename.jpeg) => that causes identify errors because of extracting metadata on an image file that doesn't exist yet
  2. storage->setFileContents(fileObject, [image data retrieved by cUrl])

Maybe that's not the right way ?

#3

Updated by Gerrit Code Review about 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65968

#4

Updated by Helmut Hummel about 2 months ago

RVVN no-lastname-given wrote:

We have a scheduler cron job that fetches remote images then stores them in fileadmin.
Images are well created at the end, but we receive emails with the mentioned errors.

I'm still puzzled why you get these warning emails.

TYPO3 logs warnings too :

Yes, that is indeed wrong and unfortunate.

We use the following sequence :

  1. storage->createFile(filename.jpeg) => that causes identify errors because of extracting metadata on an image file that doesn't exist yet
  2. storage->setFileContents(fileObject, [image data retrieved by cUrl])

Maybe that's not the right way ?

You could create a local file from CURL data and the use the addFile API instead. I will created a fix though, so that your way will not log warnings any more.

#5

Updated by Gerrit Code Review about 2 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65969

#6

Updated by Gerrit Code Review about 2 months ago

Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65969

#7

Updated by RVVN no-lastname-given about 2 months ago

Helmut Hummel wrote:

You could create a local file from CURL data and the use the addFile API instead. I will created a fix though, so that your way will not log warnings any more.

Thanks ;)

I've already tested the patch and it seems to work.
No warning in log from File.ImageInfo so I guess identify is not called.

We'll have a look at addFile method ;)

#8

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65968

#9

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66125

#10

Updated by Helmut Hummel about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF