Exporting and pictures issue

In my experience, whenever I try to export a sketch containing a PImage, loadImage and image(); functions, the sketch will fail to load those parts.
PImage I = loadImage(“hi.png”);
image(I,0,0,100,100);
this code when exported to an application will not be able to run correctly on my computer
Anyone know how to get around this, or why it happens?
Thanks in advance

1 Like

-a- please format your code so it is copy/usable

PImage I = loadImage("hi.png");
image(I,0,0,100,100);

https://processing.org/reference/loadImage_.html

ok, your code works here ( processing 3.5.3 / win7 / 64bit )
if the file with name hi.png

  • is in a subfolder /data
  • OR just with the sketch.

if not get a error

The file "hi.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
NullPointerException
Could not run the sketch (Target VM failed to initialize).
Make sure that you haven't set the maximum available memory too high.
For more information, read revisions.txt and Help ? Troubleshooting.


note: even that processing version uses that smart trick
look also in /data/ for most of the file load commands,
that does not work for file store and not for several libraries…

so i ask you to ignore that “trick” and use

String infile = "data/hi.png", outfile = "<drive>\<path>\filename"; 

variable naming:
pls do not use “I”, better “img”
-a- variables are supposed to start with small letters
( classes with big letter )
-b- “i” does not say much but is mostly used for a integer ( like in a for loop )
-c- but also never call it “image” as that is a reserved function.

1 Like

sorry about the formatting and variables, I’m new to this. The issue seemed to be that when I was exporting the sketch to an application (running in processing worked fine) the pictures weren’t put with the application so it didn’t load.

sure i tested here the export
the /data/ folder with the picture was inside the win64 app folder, under the exe.

yeah, for some reason that wan’t happening with me

there was no data folder, idk what was up with that

-a- environment

can you think of any reason why i posted this info?
so please can you tell us little bit about your setup

-b- please make it clean and document it here:
-b1- make a data subfolder and put the picture file in
-b2- make the variable

String infile = "data/hi.png"

and use it for the loadImage
-b3- export ( with the incl JAVA option )
-b4- show us the export directory tree