kovidgoyal/kitty · error
The PNG image: %s could not be opened with error: %s
Error message
The PNG image: %s could not be opened with error: %s
What it means
png_path_to_bitmap could not fopen the given PNG path for reading; the strerror(errno) explains why (No such file or directory, Permission denied, etc.). Used for the default window icon, custom window icons, and is the first failure point of the PNG loading chain.
Source
Thrown at kitty/graphics.c:567
}
pos += fread(buf + pos, sizeof(char), capacity - pos, fp);
int saved_errno = errno;
if (ferror(fp) && saved_errno != EINTR) {
log_error("Failed while reading from file: %s with error: %s", path_for_error_messages, strerror(saved_errno));
free(buf);
return false;
}
}
bool ret = png_from_data(buf, pos, path_for_error_messages, data, width, height, sz);
free(buf);
return ret;
}
bool
png_path_to_bitmap(const char *path, uint8_t **data, unsigned int *width, unsigned int *height, size_t *sz) {
FILE *fp = fopen(path, "r");
if (fp == NULL) {
log_error("The PNG image: %s could not be opened with error: %s", path, strerror(errno));
return false;
}
bool ret = png_from_file_pointer(fp, path, data, width, height, sz);
fclose(fp);
fp = NULL;
return ret;
}
bool
image_path_to_bitmap(const char *path, uint8_t **data, unsigned int *width, unsigned int *height, size_t *sz) {
*data = NULL;
*sz = 0;
*width = 0;
*height = 0;
RAII_PyObject(module, PyImport_ImportModule("kitty.render_cache"));
#define fail_on_python_error \
{ \
log_error("Failed to convert image at %s to bitmap with python error:", path); \View on GitHub (pinned to 6d5d0c4406)
Solutions
- Verify the file exists and is readable: ls -l /path/to/icon.png
- Use an absolute path (expand ~ explicitly) in kitty.conf
- Fix permissions: chmod u+r file, or correct ownership
- Remove trailing spaces/quotes from the config line
Example fix
# before (kitty.conf) background_image ~/Pictures/bg png # after background_image /home/user/Pictures/bg.png
Defensive patterns
Strategy: validation
Validate before calling
import os
def valid_image_path(p: str) -> bool:
p = os.path.expanduser(p)
return os.path.isfile(p) and os.access(p, os.R_OK) Type guard
from pathlib import Path
def is_readable_png(path: str) -> bool:
p = Path(path).expanduser()
return p.is_file() and os.access(p, os.R_OK) Prevention
- Use absolute, expanded paths in kitty.conf
- Validate icon/background paths in dotfile bootstrap scripts
- Check for typos, stray quotes, and trailing whitespace in config lines
When it happens
Trigger: set_default_window_icon / set_os_window_icon / config referencing a path that does not exist, is a directory, or lacks read permission; relative paths resolved against the wrong working directory.
Common situations: kitty.conf icon_path or background_image pointing to a moved/deleted file; '~/…' not expanded; config synced to another machine where the path differs; permissions changed after chmod; path contains a typo or trailing whitespace.
Related errors
- No custom kitten named {kitten} found
- Failed to create config directory to store favorites in: %w
- Could not find the geninclude file: {val}, ignoring
- Could not find included config file: {val}, ignoring
- Could not read from included config file: {}, ignoring
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/67de27bacd862966.
Report an issue: GitHub.