Page 1 of 1

Problem with loading an image

Posted: Sun Dec 06, 2020 8:26 pm
by HighlightKing
Hi everyone!

So I've been looking around for a while now, and can't find an explanation, let alone a solution to this issue.
I'll paste the traceback below, but before that:

- the image names in the code and the names of the actual images are matching
- the file type(jpg) is correct (though it should be irrelevant, as it is just a "show" image in the script)
- if I rename the image in the code and the actual image file (say from a1 to a1_fix), it works, but then the next image will pop up with an error. So I could rename ALL the images in the code and the actual files, but that takes a super long time and I still wouldn't know what causes the issue
- it works fine with a PC build (identical code and files) but does this in the Android build

So my question is, why is this happening, and how could I fix this WITHOUT having to rename all the images and the respective lines of code. Thank you!

Here is the traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.


While loading <'Image' 'images/a1_03.jpg'>:
Exception: Could not load image 'images/a1_03.jpg': error('JPEG loading error',)


-- Full Traceback ------------------------------------------------------------


Full traceback:
  File "xscripts/script a1.rpyc", line 114, in script
  File "renpy/ast.py", line 1389, in execute
  File "renpy/exports.py", line 1601, in with_statement
  File "renpy/display/core.py", line 2251, in do_with
  File "renpy/display/core.py", line 2702, in interact
  File "renpy/display/core.py", line 3194, in interact_core
  File "renpy/display/core.py", line 2094, in draw_screen
  File "renpy/display/render.pyx", line 490, in renpy.display.render.render_screen (gen/renpy.display.render.c:6805)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/layout.py", line 722, in render
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/transition.py", line 180, in render
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/transition.py", line 361, in render
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/layout.py", line 722, in render
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/layout.py", line 722, in render
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "accelerator.pyx", line 110, in renpy.display.accelerator.transform_render
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/image.py", line 500, in render
  File "renpy/display/image.py", line 306, in wrap_render
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
  File "renpy/display/im.py", line 583, in render
  File "renpy/display/im.py", line 266, in get
  File "renpy/display/im.py", line 628, in load
  File "renpy/display/pgrender.py", line 162, in load_image
Exception: Could not load image 'images/a1_03.jpg': error('JPEG loading error',)



Re: Problem with loading an image

Posted: Sun Dec 06, 2020 10:12 pm
by Imperf3kt
JPEG loading error suggests the file is the problem.
What is the file size of the image? I'm thinking it might be too large to load into ram.

Re: Problem with loading an image

Posted: Sun Dec 06, 2020 11:01 pm
by HighlightKing
Imperf3kt wrote:
Sun Dec 06, 2020 10:12 pm
JPEG loading error suggests the file is the problem.
What is the file size of the image? I'm thinking it might be too large to load into ram.
If that were true, why would simply renaming it fix it?

Re: Problem with loading an image

Posted: Mon Dec 07, 2020 12:53 pm
by gas
Activate the hidden extension of your OS.
In fact, there's high chances they are not
image.jpg

but
image.jpg.jpg

This happen if you MANUALLY set the extensions when you save the image. for example, in GIMP, if you select "export as JPG" the app ALREADY apply ".jpg" and if you'll input "image.jpg" there you have a double extension. This one case, others happen (for example in bad resizing apps).
The thing obviously gone when you rename it.

Window don't care and ignore the second extension, Android go crazy about.

Mistakes doesn't allow organical solutions. Rename your images.

Re: Problem with loading an image

Posted: Mon Dec 07, 2020 1:11 pm
by HighlightKing
gas wrote:
Mon Dec 07, 2020 12:53 pm
Activate the hidden extension of your OS.
In fact, there's high chances they are not
image.jpg

but
image.jpg.jpg

This happen if you MANUALLY set the extensions when you save the image. for example, in GIMP, if you select "export as JPG" the app ALREADY apply ".jpg" and if you'll input "image.jpg" there you have a double extension. This one case, others happen (for example in bad resizing apps).
The thing obviously gone when you rename it.

Window don't care and ignore the second extension, Android go crazy about.

Mistakes doesn't allow organical solutions. Rename your images.
Well, I've already checked in the properties before making this post, and they are just simply .jpg, not jpg.jpg.
And since it's not that, I don't now what other "meta data" could be the issue here. So I'm pretty sure it's something else.
And knowing what causes the issue could allow me to fix it without having to rename 1000+ images.

Re: Problem with loading an image

Posted: Mon Dec 07, 2020 1:46 pm
by gas
As changing the name work, MAYBE a batch app can solve the thing, re-encoding the name reference without changing it and keep the image as it is.
I dunno, maybe the reference use a non UTF encoding that make Android unable to parse it.
It's just a wild guess, but something I'll try.

This if everything else is verified (like using .jpg and not .jpeg and not double extension). I knew of .jpeg giving issues, but usually it was an error from the coder side.
Hopefully you'll find a practical solution.

(Anyway a batch renaming app and find/replace in the edtor can be a practical alternative if you're consistent with names, why not...).

Re: Problem with loading an image

Posted: Mon Dec 07, 2020 1:56 pm
by HighlightKing
gas wrote:
Mon Dec 07, 2020 1:46 pm
As changing the name work, MAYBE a batch app can solve the thing, re-encoding the name reference without changing it and keep the image as it is.
I dunno, maybe the reference use a non UTF encoding that make Android unable to parse it.
Yea, that's actually worth a try... renaming just the image. I'll be honest, I was so immersed in all this nonsense yesterday night, that I'm not even sure whether I've tried it or not, haha. But if that doesn't work, well... renaming manually both in the code and the images it is.

In any case, thank you for your effort! :)