Add image from my files

I’m trying to load an image that I have on my computer, but I get this error … someone can audare me …

img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg”);

the image, this name is colibri.jpg

This should work

using ImageView
img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg”);
imshow(img)
julia> using ImageView

julia> img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg”);
ERROR: syntax: invalid character "“" near column 13

julia> img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg");
ERROR: syntax: invalid character "“" near column 13

julia> img = load("C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg");
ERROR: syntax: invalid escape sequence

That’s look like some error in PATH. Just to make sure, go to the folder where the image is located

using ImageView

cd("C:\Users\gerso.julia\Imagenes_de_gerson")
# Confirm location 
pwd()
# Run again 
img = load("colibri.jpg")

See if that works.

The problem is that discourse replaces the character " with the stylish “:

julia> '"'
'"': ASCII/Unicode U+0022 (category Po: Punctuation, other)

julia> '“'
'“': Unicode U+201c (category Pi: Punctuation, initial quote)

You need to replace it when copy pasting. A real misfeature of discourse…

I think it is a nice feature. You just need to quote code with backticks.

As you can see the first post had code quotes. I don’t know exactly how it happens but multiple times i have copied code and had to replace these quotes. Very annoying.

I don’t think the OP used `s, that’s why when the second post copy-pasted the text (and quoted it), it ended up with s.

I don’t really care how it happened, I just know it happens, and the annoyance it causes me far outweighs the pleasure of slightly curved quote characters.

2 Likes
julia> using ImageView

julia> cd("C:\Users\gerso.julia\Imagenes_de_gerson")
ERROR: syntax: invalid escape sequence

julia> pwd
pwd (generic function with 1 method)

julia> img = load("colibri.jpg")
ERROR: UndefVarError: load not defined
Stacktrace:
 [1] top-level scope at none:0

julia>

Probably you meant pwd(). And you may need to be using FileIO to get load.

That’s good to know, I’ve never noticed that.

You are on Windows. Need to escape the backslashs

cd("C:\\Users\\gerso.julia\\Imagenes_de_gerson")

That’s why I use raw for something like this on Windows.

raw"C:\user\..."

Simpler to use (works on Win too)

"c:/user/..."
1 Like

True but I’ve used Windows for so long that \ is embedded in my brain!

However your approach is more portable.