godotengine / godotengine/godot

Image.save_jpg cannot save to a directory that does not yet exist.

Open
#104,236 3 comments 0 reactions 0 assignees View on GitHub
discussion documentation topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.4

### System information

Windows 11 - Godot 4.4
MacOS 15.3.1 - Godot 4.4

### Issue description

When running the Method `save_jpg` on the class Image, the Method will fail to save to a directory if it does not already exist on the disk.

This may be expected behaviour - however - The Error in the Output Log is very unspecific, reporting only:
`ERROR: Can't save JPG at path: 'res://PATH/example/...`

Would it be possible to either get the method to generate the required sub-folders needed, to save to any arbitrary path, or, get the ERROR message updated to be more descriptive as to why the JPG failed to save.

(PS - it's assumed that the same happens with the other image export types, but I have not tested these myself).

Relevent Documentation page:
https://docs.godotengine.org/en/stable/classes/class_image.html#class-image-method-save-jpg

### Steps to reproduce

1. Use the Method `save_jpg` to save an image.
2. Input a path for the image to be save to, at some sub-folder that does not yet exist.
3. Observe the ERROR.

### Minimal reproduction project (MRP)

N/A

Contributor guide

Open the contributing guide

Research direction

Start at the Image.save_jpg implementation and reproduce the reported failure using a path containing a missing subdirectory on Windows or macOS. Check how the save error is generated and compare the behavior of the other image export methods. Done means the issue's intended outcome—directory creation or a more descriptive error—is clarified and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.