Loading a png file inside a package

In one of my packages I want to load a png file using FileIO. When I try to do that, I get an error message:

t.qpa.xcb: QXcbConnection: XCB error: 5 (BadAtom), sequence: 498, resource id: 0, major code: 20 (GetProperty), minor code: 0
Errors encountered while loading nothing.
All errors:
===========================================
ArgumentError: Package ImageIO not found in current path:
- Run `import Pkg; Pkg.add("ImageIO")` to install the ImageIO package.

===========================================
ArgumentError: Package ImageMagick not found in current path:
- Run `import Pkg; Pkg.add("ImageMagick")` to install the ImageMagick package.

===========================================

Fatal error:
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: ArgumentError: Package ImageIO not found in current path:
- Run `import Pkg; Pkg.add("ImageIO")` to install the ImageIO package.

This message does not go away if I add ImageMagick or ImageIO to my dependencies, it only goes away if I add one of them to my main environment.

But I would like not to require the user to add such an extra package to the main environment. Is there a way to avoid that? One reason I want to avoid that is, that ImageIO has some issues with that PNG file, so I want to enforce ImageMagick.

2 Likes

I might have resolved that by just adding using ImageMagick inside my package although I am not sure if I am doing the right thing here