RC8: images don't appear when imported

User avatar
kalidasa
Posts: 28
Joined: Mon Nov 01, 2010 11:19 pm
Platform: Windows
Location: Wollongong, NSW, Australia
Contact:

Tue Aug 04, 2020 11:55 am Post

I tried to import some images into one of my projects using RC8 - they showed up as imported, but the images themselves were blank. Importing images worked properly in previous betas and RCs.

Annotation 2020-08-04 214514.jpg
Annotation 2020-08-04 214514.jpg (149.69 KiB) Viewed 229 times

Annotation 2020-08-04 214534.jpg
Annotation 2020-08-04 214534.jpg (136.93 KiB) Viewed 229 times

User avatar
kalidasa
Posts: 28
Joined: Mon Nov 01, 2010 11:19 pm
Platform: Windows
Location: Wollongong, NSW, Australia
Contact:

Thu Aug 13, 2020 11:33 pm Post

This issue is still occurring in RC9.

User avatar
kalidasa
Posts: 28
Joined: Mon Nov 01, 2010 11:19 pm
Platform: Windows
Location: Wollongong, NSW, Australia
Contact:

Mon Sep 14, 2020 1:47 pm Post

Issue is still happening in RC10. However it's entirely dependent on the image in question, and I'm not sure why. :/

User avatar
tiho_d
Posts: 1283
Joined: Tue Sep 13, 2011 1:14 pm
Platform: Linux + Windows

Mon Sep 14, 2020 2:12 pm Post

Some images might have the extension PNG, but internally they have JPG data due to wrong file extension upon saving from a web browser for example. This might cause troubles to the Image reader engine which expects one type of image, but indeed the image internally is totally different format. I would suggest resaving the failing images with an external image manipulation application to ensure proper file name extension. If this does not help, resave the images with a different extension. I would suggest changing between PNG <> JPG image types.

User avatar
devinganger
Posts: 2197
Joined: Sat Nov 06, 2010 1:55 pm
Platform: Mac, Win + iOS
Location: Monroe, WA 98272 (CN97au)
Contact:

Mon Sep 14, 2020 8:44 pm Post

tiho_d wrote:Some images might have the extension PNG, but internally they have JPG data due to wrong file extension upon saving from a web browser for example. This might cause troubles to the Image reader engine which expects one type of image, but indeed the image internally is totally different format.


Wait, the image reader engine depends only upon the eternal filename to determine what type of image it is? That's pretty insecure and open to potential vulnerabilities, Tiho. I hope this is being worked on that it will properly scan the image data and determine the image type from the actual data (safely protecting against malformed data, overflows, etc.)
--
Devin L. Ganger, WA7DLG
Not a L&L employee; opinions are those of my cat
Life has a way of moving you past wants and hopes

User avatar
tiho_d
Posts: 1283
Joined: Tue Sep 13, 2011 1:14 pm
Platform: Linux + Windows

Mon Sep 14, 2020 8:51 pm Post

@devinganger: Unfortunately it is the Qt engine which loads an image via file. From the file extension it deducts the plugin which should be used to load the image data from the file. If the JPEG plugin tries to load a PNG image data, obviously it will return an error, even if the file contains a valid PNG image data.

The solution to this problem is probably creating QImage from raw file data, which will pull the plugin based on file contents, but have not played with this. I just described the possible cause, which I have seen for failed imported images. At the end of the day the image file extension should match the image file contents. One should not expect animated GIF from renaming a JPEG file extension to GIF for example. Importing this renamed GIF into Scrivener will most likely fail, like the described use case above.

User avatar
devinganger
Posts: 2197
Joined: Sat Nov 06, 2010 1:55 pm
Platform: Mac, Win + iOS
Location: Monroe, WA 98272 (CN97au)
Contact:

Mon Sep 14, 2020 9:53 pm Post

tiho_d wrote:@devinganger: Unfortunately it is the Qt engine which loads an image via file. From the file extension it deducts the plugin which should be used to load the image data from the file. If the JPEG plugin tries to load a PNG image data, obviously it will return an error, even if the file contains a valid PNG image data.


Ugh, that approach is not nearly robust enough in modern computing and I am surprised that Qt does it that way. Thanks for the explanation, though.
--
Devin L. Ganger, WA7DLG
Not a L&L employee; opinions are those of my cat
Life has a way of moving you past wants and hopes